-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added SDK integration, flexible policy accounts, and general security…
… updates (#41) (#42) * make policy account resizable * resiable idenitty accounts (#35) * resiable idenitty accounts * update tests, init more tests * remove commented files * update signer checks + hash policy account (#36) * update signer checks to use only authority or delegate * policy hash + patches (#38) * generic security fixes * use hash to identify policies (#39) * use hash to identify policies * use policy account in hash * Merged resizable policies and dashboards * Updated clients rwa-token-sdk for resizable policy * Added program * update anchor binary * update idls * Rename IDL types in client * use camel case + fix eslint + fix tests partially + update anchor repo * fix tests * Added @bridgesplit/sdk update to example * Updated to support new PolicyType * Updated policy enum types * Updated examples * fix typedoc issues * fix typedoc issues * Update instructions * Updated instructions * Convention update * Updated typedoc json * Updated testing path * Removed examples * fix build yaml * update package + add lint to actions * update package naming across file * rm untracked file * Added conventions * Updated client to be coral anchor. * clear github cache * Deleted old idls * update file names * fix tests --------- Co-authored-by: Chris Hagedorn <[email protected]> Co-authored-by: Bhargava Sai Macha <[email protected]>
- Loading branch information
1 parent
3854d5b
commit 9632bac
Showing
129 changed files
with
7,454 additions
and
7,416 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,4 +6,6 @@ node_modules | |
test-ledger | ||
.yarn | ||
dist | ||
.env | ||
.env | ||
yarn-error.log | ||
docs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# RWA Conventions | ||
|
||
## Folder and File Naming Conventions | ||
|
||
### Folder Naming Convention | ||
|
||
- All folders within the clients follow the kebab-case naming convention. This means folder names are lowercase with words separated by hyphens ("-"). | ||
- All folders within the programs follow the snake*case naming convention. This means folder names are lowercase with words separated by underscores ("*"). | ||
|
||
### Component File Naming Convention | ||
|
||
- Component files within the project follow the TitleCase naming convention. This means that the first letter of each word in the filename is capitalized, and there are no spaces or special characters. For example: `MyComponent.jsx` | ||
|
||
### Helper File Naming Convention | ||
|
||
- Helper files within the project follow the lowercase naming convention. This includes files such as index files, types files, and utility files. For example: `index.ts`, `types.ts`, `utils.ts` | ||
|
||
## Folder Structure | ||
|
||
- **clients/** | ||
- Contains all RWA typescript sdk code. | ||
- **programs/** | ||
- Contains all programs deployed on the solana blockchain. | ||
|
||
## Usage | ||
|
||
To maintain consistency across the project, please adhere to the following naming conventions when creating new folders and files. This helps keep the project organized and makes it easier for team members to navigate and understand the codebase. |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,142 @@ | ||
## Client implementations | ||
### TODO: Break out TS functions into Typescript SDK | ||
### TODO: Add Rust SDK | ||
# Medici SDK Quickstart | ||
|
||
## Install Package | ||
|
||
**Step 1:** Install Medici | ||
|
||
```typescript | ||
yarn add @bridgesplit/rwa-token-sdk | ||
``` | ||
|
||
## Initialize RWA Client | ||
|
||
**Step 2:** Begin by importing the RWA client and instantiating it with its respective parameters. | ||
|
||
```typescript | ||
const connectionUrl = process.env.RPC_URL ?? "http://localhost:8899"; | ||
const connection = new Connection(connectionUrl); | ||
|
||
const confirmationOptions: ConfirmOptions = { | ||
skipPreflight: false, | ||
maxRetries: 3, | ||
commitment: "processed", | ||
}; | ||
|
||
const config: Config = { | ||
connection: connection, | ||
rpcUrl: connectionUrl, | ||
confirmationOptions: confirmationOptions, | ||
}; | ||
|
||
/* Setup: payerKp, is just the keypair who will pay for the tx. */ | ||
const rwaClient = new RwaClient(config, new Wallet(setup.payerKp)); | ||
``` | ||
|
||
## Initialize an Asset Controller | ||
|
||
**Step 3:** Initialize an asset controller on chain. | ||
|
||
```typescript | ||
const SetupAssetControllerArgs = { | ||
decimals /* Token decimals */, | ||
payer: setup.payer.toString() /* The wallet who will pay */, | ||
authority: setup.authority.toString() /* Token decimals */, | ||
name: "Test Class Asset", | ||
uri: "https://test.com", | ||
symbol: "TFT", | ||
/* | ||
You can always update name, uri, symbol later via | ||
rwaClient.dataRegistry.updateAssetsDataAccountInfoIxns() | ||
*/ | ||
}; | ||
|
||
const setupIx = await rwaClient.assetController.setUpNewRegistry( | ||
SetupAssetControllerArgs | ||
); | ||
const txnId = await sendAndConfirmTransaction( | ||
rwaClient.provider.connection, | ||
new Transaction().add(...setupIx.ixs), | ||
[setup.payerKp, ...setupIx.signers] | ||
); | ||
const mint = | ||
setupIx.signers[0].publicKey.toString(); /* Make sure to record assets mint */ | ||
``` | ||
|
||
## Setup Data Registry | ||
|
||
**Step 4:** Create the data registry account. | ||
|
||
```typescript | ||
const createDataAccountArgs: CreateDataAccountArgs = { | ||
type: { | ||
legal: {}, | ||
} /* This is where your record of legal documentation will go */, | ||
name: "Test Data Account", | ||
uri: "https://test.com", | ||
payer: setup.payer.toString(), | ||
assetMint: mint, | ||
}; | ||
|
||
/* Note: you can update the data registry later with rwaClient.dataRegistry.updateAssetsDataAccountInfoIxns() */ | ||
const createDataAccountIx = await rwaClient.dataRegistry.setupDataAccount( | ||
createDataAccountArgs | ||
); | ||
|
||
const txnId = await sendAndConfirmTransaction( | ||
rwaClient.provider.connection, | ||
new Transaction().add(...createDataAccountIx.ixs), | ||
[setup.payerKp, createDataAccountIx.signers[0]] | ||
); | ||
const dataAccount = createDataAccountIx.signers[0].publicKey.toString(); | ||
``` | ||
|
||
## Attach a Policy | ||
|
||
**Step 5:** Use the policy engine to attach policies to the asset. | ||
|
||
```typescript | ||
const policyArgs: AttachPolicyArgs = { | ||
authority: setup.authority.toString(), | ||
owner: setup.authority.toString(), | ||
assetMint: mint, | ||
payer: setup.payer.toString(), | ||
/* Identity filter is used for group specific policies */ | ||
identityFilter: { | ||
identityLevels: [1], | ||
comparisionType: { or: {} }, | ||
}, | ||
policy: { | ||
identityApproval: {}, | ||
/* | ||
The following are example policy's you can pass instead of identity approval: | ||
transactionAmountLimit: { | ||
limit: new BN(100), | ||
} | ||
transactionAmountVelocity: { | ||
limit: new BN(100000) | ||
timeframe: new BN(60) | ||
} | ||
transactionCountVelocity: { | ||
limit: new BN(100), | ||
timeframe: new BN(60), | ||
} | ||
,*/ | ||
}, | ||
}; | ||
|
||
const policyIx = await rwaClient.policyEngine.attachPolicy(policyArgs); | ||
const txnId = await sendAndConfirmTransaction( | ||
rwaClient.provider.connection, | ||
new Transaction().add(...policyIx.ixs), | ||
[setup.payerKp, ...policyIx.signers] | ||
); | ||
|
||
remainingAccounts.push(policyIx.signers[0].publicKey.toString()); | ||
``` |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.