-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add script to oparate send.devprotocol.xyz manually
- Loading branch information
Showing
2 changed files
with
61 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) }, | ||
] |