diff --git a/packages/apps/tools/src/pact/faucet/deploy.ts b/packages/apps/tools/src/pact/faucet/deploy.ts index 02a9cc48d6e..1772dd99ede 100644 --- a/packages/apps/tools/src/pact/faucet/deploy.ts +++ b/packages/apps/tools/src/pact/faucet/deploy.ts @@ -4,6 +4,7 @@ import { createAdmin } from './deploy/createAdmin'; import { deployFaucet } from './deploy/deployFaucet'; import { fundAdmin } from './deploy/fundAdmin'; import { fundFaucet } from './deploy/fundFaucet'; +import { fundGasStation } from './deploy/fundGasStation'; import { rotateKeyset } from './deploy/rotate-keyset'; const deployInOrder = () => { @@ -22,6 +23,9 @@ const deployInOrder = () => { // console.log('fundFaucet', chain, upgrade); // await fundFaucet({ chainId: chain, upgrade }); + // console.log('fundGasStation', chain, upgrade); + // await fundGasStation({ chainId: chain, upgrade }); + // console.log('rotateKeyset', chain, upgrade); // await rotateKeyset('faucet-operation', chain); }); diff --git a/packages/apps/tools/src/pact/faucet/deploy/constants.ts b/packages/apps/tools/src/pact/faucet/deploy/constants.ts index 098b7c8fdc2..2f83b2003c4 100644 --- a/packages/apps/tools/src/pact/faucet/deploy/constants.ts +++ b/packages/apps/tools/src/pact/faucet/deploy/constants.ts @@ -29,6 +29,8 @@ export const DOMAIN: export const COIN_ACCOUNT: string = 'contract-admins'; +export const GAS_STATION = 'c:clGP4RWyk9pvJHO6-f1DOMEknZGtqHtjkKn4NT2hMf0'; + export const GAS_PROVIDER: { publicKey: string; privateKey: string; diff --git a/packages/apps/tools/src/pact/faucet/deploy/fundGasStation.ts b/packages/apps/tools/src/pact/faucet/deploy/fundGasStation.ts new file mode 100644 index 00000000000..a4bb7b5642d --- /dev/null +++ b/packages/apps/tools/src/pact/faucet/deploy/fundGasStation.ts @@ -0,0 +1,57 @@ +import type { ChainwebChainId } from '@kadena/chainweb-node-client'; +import { createSignWithKeypair } from '@kadena/client'; +import { transfer } from '@kadena/client-utils/coin'; +import { + COIN_ACCOUNT, + DOMAIN, + GAS_PROVIDER, + GAS_STATION, + NETWORK_ID, +} from './constants'; + +export const fundGasStation = async ({ + chainId, + upgrade, +}: { + chainId: ChainwebChainId; + upgrade: boolean; +}) => { + if (upgrade) { + return 'The step "fundGasStation" is skipped for upgrades'; + } + + const result = await transfer( + { + sender: { + account: COIN_ACCOUNT, + publicKeys: [GAS_PROVIDER.publicKey], + }, + receiver: GAS_STATION, + amount: '1', + gasPayer: { + account: GAS_PROVIDER.accountName, + publicKeys: [GAS_PROVIDER.publicKey], + }, + chainId, + }, + { + host: ({ networkId, chainId }) => + `${DOMAIN}/chainweb/0.0/${networkId}/chain/${chainId}/pact`, + defaults: { networkId: NETWORK_ID }, + sign: createSignWithKeypair([ + { + publicKey: GAS_PROVIDER.publicKey, + secretKey: GAS_PROVIDER.privateKey, + }, + ]), + }, + ) + .on('sign', (data) => console.log(data)) + .on('preflight', (data) => console.log(data)) + .on('submit', (data) => console.log(data)) + .on('listen', (data) => console.log(data)) + .execute(); + + console.log(result); + return; +};