Skip to content

Commit d888df7

Browse files
authored
Merge pull request #77 from bridgesplit/staging
Staging
2 parents 1f3cfce + e59a52a commit d888df7

File tree

32 files changed

+866
-124
lines changed

32 files changed

+866
-124
lines changed

clients/rwa-token-sdk/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@bridgesplit/rwa-token-sdk",
3-
"version": "0.0.15",
3+
"version": "0.0.16",
44
"description": "RWA Token SDK for the development of permissioned tokens on SVM blockchains.",
55
"homepage": "https://github.com/bridgesplit/rwa-token#readme",
66
"main": "dist/index",

clients/rwa-token-sdk/src/asset-controller/instructions.ts

Lines changed: 106 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ export type CreateAssetControllerIx = {
4848
name: string;
4949
uri: string;
5050
symbol: string;
51+
interestRate?: number;
5152
} & CommonArgs;
5253

5354
/**
@@ -67,6 +68,7 @@ export async function getCreateAssetControllerIx(
6768
uri: args.uri,
6869
symbol: args.symbol,
6970
delegate: args.delegate ? new PublicKey(args.delegate) : null,
71+
interestRate: args.interestRate ? new BN(args.interestRate) : null,
7072
})
7173
.accountsStrict({
7274
payer: args.payer,
@@ -224,12 +226,12 @@ export async function getTransferTokensIx(
224226
isSigner: false,
225227
},
226228
{
227-
pubkey: getIdentityAccountPda(args.assetMint, args.from),
229+
pubkey: getIdentityAccountPda(args.assetMint, args.to),
228230
isWritable: true,
229231
isSigner: false,
230232
},
231233
{
232-
pubkey: getTrackerAccountPda(args.assetMint, args.from),
234+
pubkey: getTrackerAccountPda(args.assetMint, args.to),
233235
isWritable: true,
234236
isSigner: false,
235237
},
@@ -281,6 +283,7 @@ export async function getTransferTokensIx(
281283

282284
export type CreateTokenAccountArgs = {
283285
owner: string;
286+
transferMemo?: boolean;
284287
} & CommonArgs;
285288

286289
export async function getCreateTokenAccountIx(
@@ -289,12 +292,15 @@ export async function getCreateTokenAccountIx(
289292
): Promise<TransactionInstruction> {
290293
const assetProgram = getAssetControllerProgram(provider);
291294
const ix = await assetProgram.methods
292-
.createTokenAccount()
295+
.createTokenAccount({
296+
transferMemo: args.transferMemo || false,
297+
})
293298
.accountsStrict({
294299
payer: args.payer,
295300
assetMint: args.assetMint,
296301
owner: args.owner,
297302
tokenProgram: TOKEN_2022_PROGRAM_ID,
303+
assetController: getAssetControllerPda(args.assetMint),
298304
associatedTokenProgram: ASSOCIATED_TOKEN_PROGRAM_ID,
299305
systemProgram: SystemProgram.programId,
300306
tokenAccount: getAssociatedTokenAddressSync(
@@ -318,6 +324,8 @@ export type SetupAssetControllerArgs = {
318324
name: string;
319325
uri: string;
320326
symbol: string;
327+
interestRate?: number;
328+
transferMemo?: boolean;
321329
};
322330

323331
/**
@@ -354,12 +362,27 @@ export async function getSetupAssetControllerIxs(
354362
provider
355363
);
356364

365+
// Setup user ixs
366+
const setupUserIxs = await getSetupUserIxs(
367+
{
368+
payer: args.payer,
369+
owner: args.authority,
370+
signer: args.authority,
371+
assetMint: mint.toString(),
372+
level: 255,
373+
transferMemo: args.transferMemo,
374+
},
375+
provider
376+
);
377+
378+
357379
return {
358380
ixs: [
359381
assetControllerCreateIx,
360382
policyEngineCreateIx,
361383
dataRegistryCreateIx,
362384
identityRegistryCreateIx,
385+
...setupUserIxs.ixs,
363386
],
364387
signers: [mintKp],
365388
};
@@ -372,6 +395,7 @@ export type SetupUserArgs = {
372395
signer: string;
373396
assetMint: string;
374397
level: number;
398+
transferMemo?: boolean;
375399
};
376400

377401
/**
@@ -401,3 +425,82 @@ export async function getSetupUserIxs(
401425
signers: [],
402426
};
403427
}
428+
429+
export type InterestBearingMintArgs = {
430+
rate: number;
431+
authority: string;
432+
} & CommonArgs;
433+
434+
/**
435+
* Generate Instructions to update interest rate
436+
* @param args - {@link InterestRateArgs}
437+
* @returns - {@link TransactionInstruction}
438+
* */
439+
export async function getUpdateInterestBearingMintRateIx(
440+
args: { rate: number, authority: string } & CommonArgs,
441+
provider: AnchorProvider
442+
): Promise<TransactionInstruction> {
443+
const assetProgram = getAssetControllerProgram(provider);
444+
const ix = await assetProgram.methods
445+
.updateInterestBearingMintRate(new BN(args.rate))
446+
.accountsStrict({
447+
authority: new PublicKey(args.authority),
448+
assetMint: new PublicKey(args.assetMint),
449+
tokenProgram: TOKEN_2022_PROGRAM_ID,
450+
assetController: getAssetControllerPda(args.assetMint),
451+
})
452+
.instruction();
453+
return ix;
454+
}
455+
456+
export type MemoTranferArgs = {
457+
owner: string;
458+
tokenAccount: string;
459+
};
460+
461+
/**
462+
* Generate Instructions to disable memo transfer
463+
* @param args - {@link MemoTranferArgs}
464+
* @returns - {@link TransactionInstruction}
465+
* */
466+
export async function getDisableMemoTransferIx(
467+
args: MemoTranferArgs,
468+
provider: AnchorProvider
469+
): Promise<TransactionInstruction> {
470+
const assetProgram = getAssetControllerProgram(provider);
471+
const ix = await assetProgram.methods
472+
.disableMemoTransfer()
473+
.accountsStrict({
474+
owner: new PublicKey(args.owner),
475+
tokenAccount: new PublicKey(args.tokenAccount),
476+
tokenProgram: TOKEN_2022_PROGRAM_ID,
477+
})
478+
.instruction();
479+
return ix;
480+
}
481+
482+
export type CloseMintArgs = {
483+
authority: string;
484+
} & CommonArgs;
485+
486+
/**
487+
* Generate Instructions to close a mint
488+
* @param args - {@link CloseMintArgs}
489+
* @returns - {@link TransactionInstruction}
490+
*/
491+
export async function getCloseMintIx(
492+
args: CloseMintArgs,
493+
provider: AnchorProvider
494+
): Promise<TransactionInstruction> {
495+
const assetProgram = getAssetControllerProgram(provider);
496+
const ix = await assetProgram.methods
497+
.closeMintAccount()
498+
.accountsStrict({
499+
authority: new PublicKey(args.authority),
500+
assetMint: new PublicKey(args.assetMint),
501+
tokenProgram: TOKEN_2022_PROGRAM_ID,
502+
assetController: getAssetControllerPda(args.assetMint),
503+
})
504+
.instruction();
505+
return ix;
506+
}

clients/rwa-token-sdk/src/programs/idls/AssetController.json

Lines changed: 158 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,48 @@
77
"description": "The Asset Controller Program (ACP) enables core asset management functionality for newly issued assets, including transfer controls and transaction privacy."
88
},
99
"instructions": [
10+
{
11+
"name": "close_mint_account",
12+
"docs": [
13+
"close mint account"
14+
],
15+
"discriminator": [
16+
14,
17+
121,
18+
72,
19+
246,
20+
96,
21+
224,
22+
42,
23+
162
24+
],
25+
"accounts": [
26+
{
27+
"name": "authority",
28+
"signer": true
29+
},
30+
{
31+
"name": "asset_mint",
32+
"writable": true
33+
},
34+
{
35+
"name": "asset_controller",
36+
"pda": {
37+
"seeds": [
38+
{
39+
"kind": "account",
40+
"path": "asset_mint"
41+
}
42+
]
43+
}
44+
},
45+
{
46+
"name": "token_program",
47+
"address": "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb"
48+
}
49+
],
50+
"args": []
51+
},
1052
{
1153
"name": "close_token_account",
1254
"docs": [
@@ -365,6 +407,17 @@
365407
]
366408
}
367409
},
410+
{
411+
"name": "asset_controller",
412+
"pda": {
413+
"seeds": [
414+
{
415+
"kind": "account",
416+
"path": "asset_mint"
417+
}
418+
]
419+
}
420+
},
368421
{
369422
"name": "system_program",
370423
"address": "11111111111111111111111111111111"
@@ -378,6 +431,46 @@
378431
"address": "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"
379432
}
380433
],
434+
"args": [
435+
{
436+
"name": "args",
437+
"type": {
438+
"defined": {
439+
"name": "CreateTokenAccountArgs"
440+
}
441+
}
442+
}
443+
]
444+
},
445+
{
446+
"name": "disable_memo_transfer",
447+
"docs": [
448+
"memo transfer disable"
449+
],
450+
"discriminator": [
451+
68,
452+
156,
453+
197,
454+
9,
455+
43,
456+
91,
457+
114,
458+
19
459+
],
460+
"accounts": [
461+
{
462+
"name": "owner",
463+
"signer": true
464+
},
465+
{
466+
"name": "token_account",
467+
"writable": true
468+
},
469+
{
470+
"name": "token_program",
471+
"address": "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb"
472+
}
473+
],
381474
"args": []
382475
},
383476
{
@@ -662,6 +755,53 @@
662755
}
663756
]
664757
},
758+
{
759+
"name": "update_interest_bearing_mint_rate",
760+
"docs": [
761+
"interest bearing mint rate update"
762+
],
763+
"discriminator": [
764+
29,
765+
174,
766+
109,
767+
163,
768+
227,
769+
75,
770+
2,
771+
144
772+
],
773+
"accounts": [
774+
{
775+
"name": "authority",
776+
"signer": true
777+
},
778+
{
779+
"name": "asset_mint",
780+
"writable": true
781+
},
782+
{
783+
"name": "asset_controller",
784+
"pda": {
785+
"seeds": [
786+
{
787+
"kind": "account",
788+
"path": "asset_mint"
789+
}
790+
]
791+
}
792+
},
793+
{
794+
"name": "token_program",
795+
"address": "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb"
796+
}
797+
],
798+
"args": [
799+
{
800+
"name": "rate",
801+
"type": "i16"
802+
}
803+
]
804+
},
665805
{
666806
"name": "update_metadata",
667807
"docs": [
@@ -1052,6 +1192,24 @@
10521192
"type": {
10531193
"option": "pubkey"
10541194
}
1195+
},
1196+
{
1197+
"name": "interest_rate",
1198+
"type": {
1199+
"option": "i16"
1200+
}
1201+
}
1202+
]
1203+
}
1204+
},
1205+
{
1206+
"name": "CreateTokenAccountArgs",
1207+
"type": {
1208+
"kind": "struct",
1209+
"fields": [
1210+
{
1211+
"name": "transfer_memo",
1212+
"type": "bool"
10551213
}
10561214
]
10571215
}

0 commit comments

Comments
 (0)