Skip to content

Commit

Permalink
add script to oparate send.devprotocol.xyz manually
Browse files Browse the repository at this point in the history
  • Loading branch information
aggre committed Dec 1, 2023
1 parent 166a270 commit 5defb4f
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 0 deletions.
26 changes: 26 additions & 0 deletions scripts/send/index.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import fetch from 'cross-fetch'
import dotenv from 'dotenv'
import options from './options.mjs'

dotenv.config()

const run = async () => {
const result = await Promise.all(
options.map(({ requestId, rpcUrl, chainId, args }) =>
fetch(
'https://send.devprotocol.xyz/api/send-transactions/SwapTokensAndStakeDev',
{
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.SEND_DEVPROTOCOL_API_KEY}`,
},
body: JSON.stringify({ requestId, rpcUrl, chainId, args }),
},
).catch((err) => new Error(err)),
),
)

console.log({ result })
}

run()
35 changes: 35 additions & 0 deletions scripts/send/options.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { ZeroAddress, randomBytes, uuidV4 } from 'ethers'

/**
* Define the base options. Please rewrite the common parameters as necessary.
*/
const base = {
rpcUrl: 'https://polygon-bor.publicnode.com',
chainId: 137,
args: {
to: ZeroAddress,
property: ZeroAddress,
payload: '0x0',
gatewayAddress: ZeroAddress,
amounts: {
token: ZeroAddress,
input: 0n,
fee: 0n,
},
},
}

const createId = () => {
const id = uuidV4(randomBytes(8))
return (key) => `${id}-${key}`
}
const id = createId()

/**
* Export all the options.
*/
export default [
{ ...base, to: ZeroAddress, requestId: id(1) },
{ ...base, to: ZeroAddress, requestId: id(2) },
{ ...base, to: ZeroAddress, requestId: id(3) },
]

0 comments on commit 5defb4f

Please sign in to comment.