Skip to content

Commit

Permalink
Merge pull request #76 from moreal/minter-conf
Browse files Browse the repository at this point in the history
PDX-244: Make upstream NCG minter configurable
  • Loading branch information
moreal authored Dec 18, 2023
2 parents dcd7cb8 + f1060f7 commit 1dc31e8
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 6 deletions.
1 change: 1 addition & 0 deletions .env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ NC_VAULT_ADDRESS=
NC_VAULT_AVATAR_ADDRESS=
NC_UPSTREAM_PRIVATE_KEY=
NC_DOWNSTREAM_PRIVATE_KEY=
NC_UPSTREAM_NCG_MINTER=

NC_UPSTREAM_ACCOUNT_TYPE=
NC_UPSTREAM__KMS__KEY_ID=
Expand Down
8 changes: 8 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ const slackBot: SlackBot | null =
const avatarAddress = Address.fromHex(
getRequiredEnv("NC_VAULT_AVATAR_ADDRESS"),
);
const upstreamNcgMinter = Address.fromHex(
getEnv("NC_UPSTREAM_NCG_MINTER") ||
"47d082a115c63e7b58b1532d20e631538eafadde",
false,
);

const useRDB = getEnv("USE_RDB");
if (useRDB?.toLowerCase() === "true") {
Expand All @@ -62,6 +67,7 @@ const slackBot: SlackBot | null =
downstreamAccount,
agentAddress,
avatarAddress,
upstreamNcgMinter,
slackBot,
);
} else {
Expand All @@ -80,6 +86,7 @@ async function withRDB(
downstreamAccount: Account,
agentAddress: Address,
avatarAddress: Address,
upstreamNcgMinter: Address,
slackBot: SlackBot | null,
) {
const upstreamStartBlockIndex = BigInt(
Expand Down Expand Up @@ -110,6 +117,7 @@ async function withRDB(
upstreamGQLClient,
downstreamGQLClient,
agentAddress,
upstreamNcgMinter,
downstreamStartBlockIndex,
slackBot,
),
Expand Down
9 changes: 3 additions & 6 deletions src/sync/downstream/events/transfer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,13 @@ export async function responseTransactionsFromTransferEvents(
networkId: upstreamNetworkId,
genesisHash: upstreamGenesisHash,
startNonce: upstreamStartNonce,
ncgMinter: upstreamNcgMinter,
}: {
account: Account;
networkId: string;
genesisHash: Uint8Array;
startNonce: bigint;
ncgMinter: Address;
},
{
account: downstreamAccount,
Expand Down Expand Up @@ -53,12 +55,7 @@ export async function responseTransactionsFromTransferEvents(
? {
currency: {
...amount.currency,
minters: new Set([
Buffer.from(
"47d082a115c63e7b58b1532d20e631538eafadde",
"hex",
),
]),
minters: new Set([upstreamNcgMinter.toBytes()]),
},
rawValue: amount.rawValue,
}
Expand Down
2 changes: 2 additions & 0 deletions src/sync/downstream/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export async function processDownstreamEvents(
upstreamGQLClient: IHeadlessGraphQLClient,
downstreamGQLClient: IHeadlessGraphQLClient,
agentAddress: Address,
upstreamNcgMinter: Address,
defaultStartBlockIndex: bigint,
slackBot: SlackBot | null,
) {
Expand Down Expand Up @@ -136,6 +137,7 @@ export async function processDownstreamEvents(
networkId: upstreamNetworkId,
genesisHash: upstreamGenesisHash,
startNonce: upstreamNextTxNonce,
ncgMinter: upstreamNcgMinter,
},
{
account: downstreamAccount,
Expand Down

0 comments on commit 1dc31e8

Please sign in to comment.