Skip to content

Commit

Permalink
New fundGasStation step of deploy script
Browse files Browse the repository at this point in the history
  • Loading branch information
Sander Looijenga committed Nov 8, 2023
1 parent 6510dfd commit 829361d
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 0 deletions.
4 changes: 4 additions & 0 deletions packages/apps/tools/src/pact/faucet/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = () => {
Expand All @@ -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);
});
Expand Down
2 changes: 2 additions & 0 deletions packages/apps/tools/src/pact/faucet/deploy/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
57 changes: 57 additions & 0 deletions packages/apps/tools/src/pact/faucet/deploy/fundGasStation.ts
Original file line number Diff line number Diff line change
@@ -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;
};

0 comments on commit 829361d

Please sign in to comment.