Skip to content

Commit 37635f5

Browse files
committed
enable setting specific authorities
1 parent 20aadf1 commit 37635f5

File tree

2 files changed

+32
-16
lines changed

2 files changed

+32
-16
lines changed

packages/sdk/src/templates/arcadeToken.ts

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,13 @@ import { createNoopSigner } from 'gill';
2121
* @param symbol - The symbol of the arcade token.
2222
* @param decimals - The number of decimals for the arcade token.
2323
* @param uri - The URI pointing to the arcade token's metadata.
24-
* @param authority - The address with authority over the mint.
24+
* @param mintAuthority - The address with authority over the mint.
2525
* @param mint - The address of the mint account to initialize.
2626
* @param feePayer - The address that will pay the transaction fees.
27+
* @param metadataAuthority - The address with authority over the metadata.
28+
* @param pausableAuthority - The address with authority over the pausable functionality.
29+
* @param confidentialBalancesAuthority - The address with authority over the confidential balances extension.
30+
* @param permanentDelegateAuthority - The address with authority over the permanent delegate.
2731
* @returns A promise that resolves to a FullTransaction object for initializing the arcade token mint.
2832
*/
2933
export const createArcadeTokenInitTransaction = async (
@@ -32,16 +36,20 @@ export const createArcadeTokenInitTransaction = async (
3236
symbol: string,
3337
decimals: number,
3438
uri: string,
35-
authority: Address,
39+
mintAuthority: Address,
3640
mint: Address,
37-
feePayer: Address
41+
feePayer: Address,
42+
metadataAuthority?: Address,
43+
pausableAuthority?: Address,
44+
confidentialBalancesAuthority?: Address,
45+
permanentDelegateAuthority?: Address
3846
): Promise<
3947
FullTransaction<TransactionVersion, TransactionMessageWithFeePayer>
4048
> => {
4149
const tx = await new Token()
4250
.withMetadata({
4351
mintAddress: mint,
44-
authority: authority,
52+
authority: metadataAuthority || mintAuthority,
4553
metadata: {
4654
name,
4755
symbol,
@@ -50,14 +58,14 @@ export const createArcadeTokenInitTransaction = async (
5058
// TODO: add additional metadata
5159
additionalMetadata: new Map(),
5260
})
53-
.withPausable(authority)
61+
.withPausable(pausableAuthority || mintAuthority)
5462
.withDefaultAccountState(true)
55-
.withConfidentialBalances(authority)
56-
.withPermanentDelegate(authority)
63+
.withConfidentialBalances(confidentialBalancesAuthority || mintAuthority)
64+
.withPermanentDelegate(permanentDelegateAuthority || mintAuthority)
5765
.buildTransaction({
5866
rpc,
5967
decimals,
60-
authority,
68+
authority: mintAuthority,
6169
mint: createNoopSigner(mint),
6270
feePayer: createNoopSigner(feePayer),
6371
});

packages/sdk/src/templates/stablecoin.ts

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,13 @@ import { createNoopSigner } from 'gill';
2020
* @param symbol - The symbol of the stablecoin.
2121
* @param decimals - The number of decimals for the stablecoin.
2222
* @param uri - The URI pointing to the stablecoin's metadata.
23-
* @param authority - The address with authority over the mint.
23+
* @param mintAuthority - The address with authority over the mint.
2424
* @param mint - The address of the mint account to initialize.
2525
* @param feePayer - The address that will pay the transaction fees.
26+
* @param metadataAuthority - The address with authority over the metadata.
27+
* @param pausableAuthority - The address with authority over the pausable functionality.
28+
* @param confidentialBalancesAuthority - The address with authority over the confidential balances extension.
29+
* @param permanentDelegateAuthority - The address with authority over the permanent delegate.
2630
* @returns A promise that resolves to a FullTransaction object for initializing the stablecoin mint.
2731
*/
2832
export const createStablecoinInitTransaction = async (
@@ -31,16 +35,20 @@ export const createStablecoinInitTransaction = async (
3135
symbol: string,
3236
decimals: number,
3337
uri: string,
34-
authority: Address,
38+
mintAuthority: Address,
3539
mint: Address,
36-
feePayer: Address
40+
feePayer: Address,
41+
metadataAuthority?: Address,
42+
pausableAuthority?: Address,
43+
confidentialBalancesAuthority?: Address,
44+
permanentDelegateAuthority?: Address
3745
): Promise<
3846
FullTransaction<TransactionVersion, TransactionMessageWithFeePayer>
3947
> => {
4048
const tx = await new Token()
4149
.withMetadata({
4250
mintAddress: mint,
43-
authority: authority,
51+
authority: metadataAuthority || mintAuthority,
4452
metadata: {
4553
name,
4654
symbol,
@@ -49,14 +57,14 @@ export const createStablecoinInitTransaction = async (
4957
// TODO: add additional metadata
5058
additionalMetadata: new Map(),
5159
})
52-
.withPausable(authority)
60+
.withPausable(pausableAuthority || mintAuthority)
5361
.withDefaultAccountState(true)
54-
.withConfidentialBalances(authority)
55-
.withPermanentDelegate(authority)
62+
.withConfidentialBalances(confidentialBalancesAuthority || mintAuthority)
63+
.withPermanentDelegate(permanentDelegateAuthority || mintAuthority)
5664
.buildTransaction({
5765
rpc,
5866
decimals,
59-
authority,
67+
authority: mintAuthority,
6068
mint: createNoopSigner(mint),
6169
feePayer: createNoopSigner(feePayer),
6270
});

0 commit comments

Comments
 (0)