Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added SDK integration, flexible policy accounts, and general security updates #41

Merged
merged 36 commits into from
Apr 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
003c4a5
make policy account resizable
Bhargavamacha Mar 20, 2024
255b8e2
resiable idenitty accounts (#35)
Bhargavamacha Mar 21, 2024
578e2c2
update signer checks + hash policy account (#36)
Bhargavamacha Apr 10, 2024
bdc5274
Merged resizable policies and dashboards
ChrisHagedorn Apr 12, 2024
20a275f
Updated clients rwa-token-sdk for resizable policy
ChrisHagedorn Apr 12, 2024
9621d5a
Added program
ChrisHagedorn Apr 12, 2024
3fd1675
update anchor binary
Bhargavamacha Apr 12, 2024
ab3778a
update idls
Bhargavamacha Apr 12, 2024
4e03b23
Rename IDL types in client
ChrisHagedorn Apr 12, 2024
1b33bc1
use camel case + fix eslint + fix tests partially + update anchor repo
Bhargavamacha Apr 15, 2024
ce35bc9
fix tests
Bhargavamacha Apr 15, 2024
544bbde
Added @bridgesplit/sdk update to example
ChrisHagedorn Apr 16, 2024
e63930c
Updated to support new PolicyType
ChrisHagedorn Apr 16, 2024
2de327b
Updated policy enum types
ChrisHagedorn Apr 16, 2024
640937d
Updated examples
ChrisHagedorn Apr 16, 2024
5be4d57
fix typedoc issues
Bhargavamacha Apr 17, 2024
bb3a517
fix typedoc issues
Bhargavamacha Apr 17, 2024
5a82598
Update instructions
ChrisHagedorn Apr 17, 2024
b9eee27
Merge branch 'fix/resizable-policies-and-dashboards/no-program' of ht…
ChrisHagedorn Apr 17, 2024
a8069ed
Updated instructions
ChrisHagedorn Apr 17, 2024
1653120
Convention update
ChrisHagedorn Apr 17, 2024
2fc72bc
Updated typedoc json
ChrisHagedorn Apr 17, 2024
3e93ebf
Updated testing path
ChrisHagedorn Apr 17, 2024
40c7947
Removed examples
ChrisHagedorn Apr 17, 2024
88deb51
fix build yaml
Bhargavamacha Apr 17, 2024
56c57a0
update package + add lint to actions
Bhargavamacha Apr 17, 2024
8d43dae
update package naming across file
Bhargavamacha Apr 17, 2024
a29594f
rm untracked file
Bhargavamacha Apr 17, 2024
4392ec0
Added conventions
ChrisHagedorn Apr 17, 2024
0d1d7e8
Merge branch 'release/ts-sdk' of https://github.com/bridgesplit/rwa-t…
ChrisHagedorn Apr 17, 2024
0048d77
Updated client to be coral anchor.
ChrisHagedorn Apr 17, 2024
dc9330a
clear github cache
Bhargavamacha Apr 17, 2024
3471b4a
Merge branch 'release/ts-sdk' of https://github.com/bridgesplit/rwa-t…
ChrisHagedorn Apr 17, 2024
3faf8ec
Deleted old idls
ChrisHagedorn Apr 17, 2024
5c6da62
update file names
Bhargavamacha Apr 17, 2024
3d3526e
fix tests
Bhargavamacha Apr 17, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 19 additions & 8 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
name: build
env:
cli-id: anchor-v0.29.2-solana-1.17.0
cli-id: anchor-v0.30.0-solana-1.18.8
on:
push:
branches:
- '*'
pull_request:
branches:
- 'main'
- '*'
jobs:
build-cli-deps:
runs-on: ubicloud-standard-8
Expand All @@ -15,17 +18,22 @@ jobs:
key: $${{ env.cli-id }}
path: |
~/.local/share/solana
~/.cargo/bin/anchor
- id: install-os-deps
if: steps.cache-cli-deps.outputs.cache-hit != 'true'
run: sudo apt-get update && sudo apt-get install -y pkg-config build-essential libudev-dev

- id: install-solana-tools
if: steps.cache-cli-deps.outputs.cache-hit != 'true'
run: sh -c "$(curl -sSfL https://release.solana.com/v1.17.0/install)"
run: sh -c "$(curl -sSfL https://release.solana.com/v1.18.8/install)"

- run: echo "PATH=$HOME/.local/share/solana/install/active_release/bin:$PATH" >> $GITHUB_ENV

tests:
- id: install-anchor-cli
if: steps.cache-cli-deps.outputs.cache-hit != 'true'
run: cargo install --git https://github.com/bridgesplit/anchor anchor-cli --locked

build:
runs-on: ubicloud-standard-8
needs: [build-cli-deps]
steps:
Expand All @@ -35,20 +43,23 @@ jobs:
key: $${{ env.cli-id }}
path: |
~/.local/share/solana
~/.cargo/bin/anchor
- id: install-os-deps
run: sudo apt-get update && sudo apt-get install -y pkg-config build-essential libudev-dev

- run: echo "PATH=$HOME/.local/share/solana/install/active_release/bin:$HOME/.cargo/bin:$PATH" >> $GITHUB_ENV
- uses: actions/setup-node@v2
with:
node-version: '18'
node-version: '20'

- uses: actions/checkout@v2
with:
fetch-depth: 0

- run: cd clients/rwa-sdk && yarn install
- run: cd clients/rwa-token-sdk && yarn install
- run: cd clients/rwa-token-sdk && yarn lint
- run: solana-keygen new --no-bip39-passphrase
- run: cd programs && cargo fmt -- --check
- run: cd programs && cargo clippy -- -D warnings
- run: cd programs && ./anchor build
- run: cd programs && ./anchor test
- run: cd programs && anchor build
- run: cd programs && anchor test
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@ node_modules
test-ledger
.yarn
dist
.env
.env
yarn-error.log
docs
27 changes: 27 additions & 0 deletions CONVENTIONS.md
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.
26 changes: 0 additions & 26 deletions README.md

This file was deleted.

1 change: 0 additions & 1 deletion cli/README.md

This file was deleted.

145 changes: 142 additions & 3 deletions clients/README.md
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());
```
37 changes: 0 additions & 37 deletions clients/rwa-sdk/.eslintrc.js

This file was deleted.

24 changes: 0 additions & 24 deletions clients/rwa-sdk/package.json

This file was deleted.

21 changes: 0 additions & 21 deletions clients/rwa-sdk/src/asset_controller/data.ts

This file was deleted.

4 changes: 0 additions & 4 deletions clients/rwa-sdk/src/asset_controller/index.ts

This file was deleted.

Loading
Loading