-
Notifications
You must be signed in to change notification settings - Fork 7
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
feat(ETH/POL): Added support for ETH and POL/matic wallets. #9
base: main
Are you sure you want to change the base?
Changes from all commits
4aa32ba
691af95
0a1ca98
82ba339
71d53c5
87cdbbf
e30abc3
e54814c
ca3859b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,16 @@ | ||
#!/usr/bin/env node | ||
|
||
import { ANT, ArweaveSigner } from '@ar.io/sdk'; | ||
import { EthereumSigner, TurboFactory } from '@ardrive/turbo-sdk'; | ||
import fs from 'fs'; | ||
import yargs from 'yargs'; | ||
import { hideBin } from 'yargs/helpers'; | ||
|
||
import TurboDeploy from './turbo'; | ||
|
||
const argv = yargs(hideBin(process.argv)) | ||
.option('ant-process', { | ||
alias: 'a', | ||
type: 'string', | ||
description: 'The ANT process', | ||
description: 'The ANT process.', | ||
demandOption: true, | ||
}) | ||
.option('deploy-folder', { | ||
|
@@ -25,6 +24,13 @@ const argv = yargs(hideBin(process.argv)) | |
type: 'string', | ||
description: 'ANT undername to update.', | ||
default: '@', | ||
}) | ||
.option('sig-type', { | ||
alias: 's', | ||
type: 'string', | ||
description: 'The type of signer to be used for deployment.', | ||
choices: ['arweave', 'ethereum', 'polygon'], | ||
default: 'arweave', | ||
}).argv; | ||
|
||
const DEPLOY_KEY = process.env.DEPLOY_KEY; | ||
|
@@ -67,29 +73,80 @@ export function getTagValue(list, name) { | |
return; | ||
} | ||
|
||
let jwk = JSON.parse(Buffer.from(DEPLOY_KEY, 'base64').toString('utf-8')); | ||
try { | ||
const manifestId = await TurboDeploy(argv, jwk); | ||
const signer = new ArweaveSigner(jwk); | ||
let signer; | ||
let token; | ||
|
||
// Creates the proper signer based on the sig-type value | ||
switch (argv['sig-type']) { | ||
case 'ethereum': | ||
signer = new EthereumSigner(DEPLOY_KEY); | ||
token = 'ethereum'; | ||
break; | ||
case 'polygon': | ||
signer = new EthereumSigner(DEPLOY_KEY); | ||
token = 'pol'; | ||
break; | ||
case 'arweave': | ||
const parsedKey = JSON.parse(Buffer.from(DEPLOY_KEY, 'base64').toString('utf-8')); // Parse DEPLOY_KEY for Arweave | ||
signer = new ArweaveSigner(parsedKey); | ||
token = 'arweave'; | ||
break; | ||
default: | ||
throw new Error( | ||
`Invalid sig-type provided: ${argv['sig-type']}. Allowed values are 'arweave', 'ethereum', or 'polygon'.` | ||
); | ||
} | ||
|
||
const turbo = TurboFactory.authenticated({ | ||
signer: signer, | ||
token: token, | ||
}); | ||
|
||
const uploadResult = await turbo.uploadFolder({ | ||
folderPath: argv['deploy-folder'], | ||
dataItemOpts: { | ||
tags: [ | ||
{ | ||
name: 'App-Name', | ||
value: 'Permaweb-Deploy', | ||
}, | ||
// prevents identical transaction Ids from eth wallets | ||
{ | ||
name: 'anchor', | ||
value: new Date().toISOString(), | ||
}, | ||
], | ||
}, | ||
}); | ||
|
||
const manifestId = uploadResult.manifestResponse.id; | ||
|
||
//TODO: Add support for custom AO network configurations. | ||
const ant = ANT.init({ processId: ANT_PROCESS, signer }); | ||
Bobinstein marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
// Update the ANT record (assumes the JWK is a controller or owner) | ||
// Update the ANT record (assumes the signer is a controller or owner) | ||
await ant.setRecord( | ||
{ | ||
undername: argv.undername, | ||
transactionId: manifestId, | ||
ttlSeconds: 3600, | ||
},{ | ||
}, | ||
{ | ||
tags: [ | ||
{ | ||
name: 'GIT-HASH', | ||
value: process.env.GITHUB_SHA, | ||
value: process.env.GITHUB_SHA || '', | ||
}, | ||
{ | ||
name: 'App-Name', | ||
value: 'Permaweb-Deploy', | ||
}, | ||
] | ||
{ | ||
name: 'anchor', | ||
value: new Date().toISOString(), | ||
}, | ||
], | ||
Comment on lines
129
to
+149
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could add options for custom tags in the cli here There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agreed, but this is outside the scope of this pr. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. no need to add anchor here - the github sha will be unique - and i believe we add this anchor in the ario sdk already |
||
} | ||
); | ||
|
||
|
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a thought here, would be preferable to store as json string. B64 encoding doesnt actually gain any protection - its still a string, just like a json string, and requires more work to decode it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And considering eth and pol wallets dont use b64 encoding... well it seems even stranger to still have this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True, but updating the required method for providing an Arweave wallet's jwk would be a major breaking change. It should be discussed in more detail with the repo owner directly before any community prs are made to address it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@twilson63 wdyt? I think either we stick to b64 encoding at all times or revert it for arweave addresses.