From c118fad42075c82fe0587450e4b95ac26b81a9ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hernando=20Guzm=C3=A1n?= Date: Mon, 28 Jun 2021 15:58:40 -0300 Subject: [PATCH] Add wallet address addition --- src/index.ts | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/index.ts b/src/index.ts index 275d0cc..5141fc2 100644 --- a/src/index.ts +++ b/src/index.ts @@ -30,9 +30,10 @@ const main = async (): Promise => { for (const user of modifiedUsers) { // Start of Ledger modifications logic - const { discordId, username, discourse, github } = user + const { discordId, username, discourse, github, address } = user console.log(`\nChecking ledger entry for ${username}...`) + // Find account by Discord ID const discordAccount = ledger.accountByAddress( `N\u0000sourcecred\u0000discord\u0000MEMBER\u0000user\u0000${discordId}\u0000` ) @@ -47,6 +48,7 @@ const main = async (): Promise => { const discordIdentityId = discordAccount.identity.id + // Merge Discourse identity if specified if (discourse) { const discourseAccount = ledger.accountByAddress( `N\u0000sourcecred\u0000discourse\u0000user\u0000https://forum.1hive.org\u0000${discourse}\u0000` @@ -72,6 +74,7 @@ const main = async (): Promise => { } } + // Merge GitHub identity if specified if (github) { const githubAccount = ledger.accountByAddress( `N\u0000sourcecred\u0000github\u0000USERLIKE\u0000USER\u0000${github}\u0000` @@ -96,7 +99,21 @@ const main = async (): Promise => { } } } + + // Add wallet address + if ( + !discordAccount.payoutAddresses.size || + discordAccount.payoutAddresses.values().next().value !== address + ) { + ledger.setPayoutAddress( + discordAccount.identity.id, + address, + '100', + '0x71850b7E9Ee3f13Ab46d67167341E4bDc905Eef9' + ) + } + // Activate account if (!discordAccount.active) { try { ledger.activate(discordIdentityId)