-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Robert Leonard
authored and
Robert Leonard
committed
Jul 9, 2024
1 parent
82e699a
commit cb496d4
Showing
4 changed files
with
182 additions
and
1 deletion.
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,58 @@ | ||
import { | ||
confirmationsFlag, | ||
feesFlag, gatekeeperNetworkFlag, | ||
gatewayTokenAddressFlag, | ||
chainFlag, parseFlagsWithPrivateKey, | ||
privateKeyFlag, gasLimitFlag, | ||
gatewayNetworkAddressFlag, | ||
} from '../utils/oclif/flags' | ||
import {Args, Command, Flags} from '@oclif/core' | ||
import {makeGatewayNetworkTs, makeGatewayTs} from '../utils/oclif/utils' | ||
import { utils, Wallet } from 'ethers'; | ||
|
||
export default class FreezeToken extends Command { | ||
static description = 'Gatekeeper can freeze tokens they issued'; | ||
|
||
static examples = [ | ||
`$ gateway-eth freeze-token 0x893F4Be53274353CD3379C87C8fd1cb4f8458F94 -n 123 | ||
`, | ||
]; | ||
|
||
static flags = { | ||
help: Flags.help({char: 'h'}), | ||
privateKey: privateKeyFlag(), | ||
gatewayTokenAddress: gatewayTokenAddressFlag(), | ||
gatekeeperNetwork: gatekeeperNetworkFlag(), | ||
gatewayNetworkAddress: gatewayNetworkAddressFlag(), | ||
chain: chainFlag(), | ||
fees: feesFlag(), | ||
gasLimit: gasLimitFlag(), | ||
confirmations: confirmationsFlag(), | ||
}; | ||
|
||
static args = { | ||
tokenOwner: Args.string({name: 'tokenOwner', required: true, description: 'Owner of the specified gateway token'}), | ||
networkName: Args.string({name: 'networkName', required: true, description: 'Name of the network'}), | ||
} | ||
|
||
async run(): Promise<void> { | ||
const {args, flags} = await this.parse(FreezeToken) | ||
|
||
const tokenOwner: string = args.tokenOwner | ||
const parsedFlags = parseFlagsWithPrivateKey(flags) | ||
|
||
|
||
const gatewayNetwork = await makeGatewayNetworkTs(parsedFlags) | ||
const gatewayTokenTs = await makeGatewayTs(parsedFlags) | ||
|
||
const networkId = await gatewayNetwork.getNetworkId(utils.formatBytes32String(args.networkName)); | ||
const sendableTransaction = await gatewayTokenTs.freeze(tokenOwner, networkId.valueOf() as bigint) | ||
|
||
const receipt = await sendableTransaction.wait(flags.confirmations) | ||
|
||
this.log( | ||
`Froze gateway token. TxHash: ${receipt.transactionHash}`, | ||
) | ||
} | ||
} | ||
|
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
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,58 @@ | ||
import { | ||
confirmationsFlag, | ||
feesFlag, gatekeeperNetworkFlag, | ||
gatewayTokenAddressFlag, | ||
chainFlag, parseFlagsWithPrivateKey, | ||
privateKeyFlag, gasLimitFlag, | ||
gatewayNetworkAddressFlag, | ||
} from '../utils/oclif/flags' | ||
import {Args, Command, Flags} from '@oclif/core' | ||
import {makeGatewayNetworkTs, makeGatewayTs} from '../utils/oclif/utils' | ||
import { utils, Wallet } from 'ethers'; | ||
|
||
export default class RevokeToken extends Command { | ||
static description = 'Gatekeeper can revoke tokens they issued'; | ||
|
||
static examples = [ | ||
`$ gateway-eth revoke-token 0x893F4Be53274353CD3379C87C8fd1cb4f8458F94 -n 123 | ||
`, | ||
]; | ||
|
||
static flags = { | ||
help: Flags.help({char: 'h'}), | ||
privateKey: privateKeyFlag(), | ||
gatewayTokenAddress: gatewayTokenAddressFlag(), | ||
gatekeeperNetwork: gatekeeperNetworkFlag(), | ||
gatewayNetworkAddress: gatewayNetworkAddressFlag(), | ||
chain: chainFlag(), | ||
fees: feesFlag(), | ||
gasLimit: gasLimitFlag(), | ||
confirmations: confirmationsFlag(), | ||
}; | ||
|
||
static args = { | ||
tokenOwner: Args.string({name: 'tokenOwner', required: true, description: 'Owner of the specified gateway token'}), | ||
networkName: Args.string({name: 'networkName', required: true, description: 'Name of the network'}), | ||
} | ||
|
||
async run(): Promise<void> { | ||
const {args, flags} = await this.parse(RevokeToken) | ||
|
||
const tokenOwner: string = args.tokenOwner | ||
const parsedFlags = parseFlagsWithPrivateKey(flags) | ||
|
||
|
||
const gatewayNetwork = await makeGatewayNetworkTs(parsedFlags) | ||
const gatewayTokenTs = await makeGatewayTs(parsedFlags) | ||
|
||
const networkId = await gatewayNetwork.getNetworkId(utils.formatBytes32String(args.networkName)); | ||
const sendableTransaction = await gatewayTokenTs.revoke(tokenOwner, networkId.valueOf() as bigint) | ||
|
||
const receipt = await sendableTransaction.wait(flags.confirmations) | ||
|
||
this.log( | ||
`Revoked gateway token. TxHash: ${receipt.transactionHash}`, | ||
) | ||
} | ||
} | ||
|
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,65 @@ | ||
import { | ||
confirmationsFlag, | ||
feesFlag, gatekeeperNetworkFlag, | ||
gatewayTokenAddressFlag, | ||
chainFlag, parseFlagsWithPrivateKey, | ||
privateKeyFlag, gasLimitFlag, | ||
gatewayNetworkAddressFlag, | ||
} from '../utils/oclif/flags' | ||
import {Args, Command, Flags} from '@oclif/core' | ||
import {makeGatewayNetworkTs, makeGatewayTs} from '../utils/oclif/utils' | ||
import { utils, Wallet } from 'ethers'; | ||
|
||
export default class UnfreezeToken extends Command { | ||
static description = 'Gatekeeper can unfreeze tokens they issued'; | ||
|
||
static examples = [ | ||
`$ gateway-eth unfreeze-token 0x893F4Be53274353CD3379C87C8fd1cb4f8458F94 -n 123 | ||
`, | ||
]; | ||
|
||
static flags = { | ||
help: Flags.help({char: 'h'}), | ||
privateKey: privateKeyFlag(), | ||
gatewayTokenAddress: gatewayTokenAddressFlag(), | ||
gatekeeperNetwork: gatekeeperNetworkFlag(), | ||
gatewayNetworkAddress: gatewayNetworkAddressFlag(), | ||
chain: chainFlag(), | ||
fees: feesFlag(), | ||
gasLimit: gasLimitFlag(), | ||
confirmations: confirmationsFlag(), | ||
}; | ||
|
||
static args = { | ||
tokenOwner: Args.string({name: 'tokenOwner', required: true, description: 'Owner of the specified gateway token'}), | ||
networkName: Args.string({name: 'networkName', required: true, description: 'Name of the network'}), | ||
feeSender: Args.string({name: 'feeSender', required: true, description: "Address that will be paying the fee"}), | ||
} | ||
|
||
async run(): Promise<void> { | ||
const {args, flags} = await this.parse(UnfreezeToken) | ||
|
||
const tokenOwner: string = args.tokenOwner | ||
const parsedFlags = parseFlagsWithPrivateKey(flags) | ||
|
||
|
||
const gatewayNetwork = await makeGatewayNetworkTs(parsedFlags) | ||
const gatewayTokenTs = await makeGatewayTs(parsedFlags) | ||
|
||
const networkId = await gatewayNetwork.getNetworkId(utils.formatBytes32String(args.networkName)); | ||
const feeRecipient = (new Wallet(parsedFlags.privateKey)).address | ||
|
||
const sendableTransaction = await gatewayTokenTs.unfreeze( | ||
tokenOwner, | ||
networkId.valueOf() as bigint, | ||
{feeRecipient , feeSender: args.feeSender} | ||
) | ||
|
||
const receipt = await sendableTransaction.wait(flags.confirmations) | ||
|
||
this.log( | ||
`Unfroze gateway token. TxHash: ${receipt.transactionHash}`, | ||
) | ||
} | ||
} | ||
|