Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move aptos cli/freeze and block cmds #1174

Open
wants to merge 6 commits into
base: goulding/krak/aptops-v2-examples
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions examples/oft-adapter-aptos-move/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,21 @@ Window is the number of seconds over which the capacity is restored. If the rate
pnpm run lz:sdk:move:adapter-unset-rate-limit --oapp-config move.layerzero.config.ts --to-eid number
```

## Blocklist Wallet

To block or unblock a specific wallet address:

```bash
# To block a wallet
pnpm run lz:sdk:move:adapter-blocklist-wallet --oapp-config move.layerzero.config.ts --wallet-address <your-wallet-address> --block true
```

To unblock a wallet:

```bash
pnpm run lz:sdk:move:adapter-blocklist-wallet --oapp-config move.layerzero.config.ts --wallet-address <your-wallet-address> --block false
```

## Permanently Disable Blocklist

> ⚠️ **Warning**: This will permanently disable the blocklist for the OFT. It is for OFTs that want to demonstrate to their holders that they will never use blocklisting abilities.
Expand Down Expand Up @@ -204,6 +219,7 @@ To transfer the Move-VM object owner, run the following command:
```bash
pnpm run lz:sdk:move:transfer-object-owner --new-owner <new-owner-address>
```

Note: The object owner has the upgrade authority for the Object.

### Mint to Account on Move VM OFT:
Expand Down
1 change: 1 addition & 0 deletions examples/oft-adapter-aptos-move/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"lint:sol": "solhint 'contracts/**/*.sol'",
"lz:sdk:evm:wire": "ts-node scripts/cli.ts --vm evm --op wire",
"lz:sdk:help": "ts-node scripts/cli.ts --op help --filter all",
"lz:sdk:move:adapter-blocklist-wallet": "ts-node scripts/cli.ts --vm move --op adapter-blocklist-wallet",
"lz:sdk:move:adapter-permanently-disable-blocklist": "ts-node scripts/cli.ts --vm move --op adapter-permanently-disable-blocklist",
"lz:sdk:move:adapter-set-fee": "ts-node scripts/cli.ts --vm move --op adapter-set-fee",
"lz:sdk:move:adapter-set-rate-limit": "ts-node scripts/cli.ts --vm move --op adapter-set-rate-limit",
Expand Down
29 changes: 29 additions & 0 deletions examples/oft-aptos-move/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,22 @@ Window is the number of seconds over which the capacity is restored. If the rate
pnpm run lz:sdk:move:unset-rate-limit --oapp-config move.layerzero.config.ts --to-eid number
```

## Blocklist Wallet

To block or unblock a specific wallet address:

```bash
pnpm run lz:sdk:move:blocklist-wallet --oapp-config move.layerzero.config.ts --wallet-address <wallet-address> --block true
```

To unblock a wallet:

```bash
pnpm run lz:sdk:move:blocklist-wallet --oapp-config move.layerzero.config.ts --wallet-address <wallet-address> --block false
```

This command allows you to add or remove addresses from the blocklist. Blocked addresses will not be able to send or receive tokens.

## Permanently Disable Blocklist

> ⚠️ **Warning**: This will permanently disable the blocklist for the OFT. It is for OFTs that want to demonstrate to their holders that they will never use blocklisting abilities.
Expand All @@ -165,6 +181,18 @@ pnpm run lz:sdk:move:unset-rate-limit --oapp-config move.layerzero.config.ts --t
pnpm run lz:sdk:move:permanently-disable-blocklist
```

## Freeze Wallet

```bash
pnpm run lz:sdk:move:freeze-wallet --oapp-config move.layerzero.config.ts --wallet-address <wallet-address> --freeze true
```

To unfreeze a wallet:

```bash
pnpm run lz:sdk:move:freeze-wallet --oapp-config move.layerzero.config.ts --wallet-address <wallet-address> --freeze false
```

## Permanently Disable Freezing

> ⚠️ **Warning**: This will permanently disable the freezing for the OFT. It is for OFTs that want to demonstrate to their holders that they will never use the freezing ability.
Expand Down Expand Up @@ -213,6 +241,7 @@ To transfer the Move-VM object owner, run the following command:
```bash
pnpm run lz:sdk:move:transfer-object-owner --new-owner <new-owner-address>
```

Note: The object owner has the upgrade authority for the Object.

### Mint to Account on Move VM OFT:
Expand Down
2 changes: 2 additions & 0 deletions examples/oft-aptos-move/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@
"lint:sol": "solhint 'contracts/**/*.sol'",
"lz:sdk:evm:wire": "ts-node scripts/cli.ts --vm evm --op wire",
"lz:sdk:help": "ts-node scripts/cli.ts --op help --filter all",
"lz:sdk:move:blocklist-wallet": "ts-node scripts/cli.ts --vm move --op blocklist-wallet",
"lz:sdk:move:build": "ts-node scripts/cli.ts --vm move --op build",
"lz:sdk:move:deploy": "ts-node scripts/cli.ts --vm move --op deploy",
"lz:sdk:move:freeze-wallet": "ts-node scripts/cli.ts --vm move --op freeze-wallet",
"lz:sdk:move:init-fa": "ts-node scripts/cli.ts --vm move --op init-fa",
"lz:sdk:move:mint-to-move-oft": "ts-node scripts/cli.ts --vm move --op mint-to-move-oft",
"lz:sdk:move:permanently-disable-blocklist": "ts-node scripts/cli.ts --vm move --op permanently-disable-blocklist",
Expand Down
37 changes: 19 additions & 18 deletions packages/devtools-extensible-cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,29 +8,30 @@ When you go to type your new operation, the args will have `-` instead of `_`.
For example, `oapp_config` will be `--oapp-config` on the command line.

```ts
import { build as buildMove } from '../../tasks/move/build'
import { INewOperation } from './NewOperation'
import { build as buildMove } from "../../tasks/move/build";
import { INewOperation } from "./NewOperation";

class MoveBuildOperation implements INewOperation {
// the vm to use
vm = 'move'
// the name of this operation
operation = 'build'
// the required arguments for the operation
reqArgs = ['oapp_config', 'named_addresses', 'move_deploy_script']
// arguments that you want to create in addition to the pre-defined ones
addArgs = []

// the implementation of the operation
async impl(args: any): Promise<void> {
await buildMove(args)
}
// the vm to use
vm = "move";
// the name of this operation
operation = "build";
// the required arguments for the operation
reqArgs = ["oapp_config", "named_addresses", "move_deploy_script"];
// arguments that you want to create in addition to the pre-defined ones
addArgs = [];

// the implementation of the operation
async impl(args: any): Promise<void> {
await buildMove(args);
}
}

const NewOperation = new MoveBuildOperation()
export { NewOperation }
const NewOperation = new MoveBuildOperation();
export { NewOperation };
```

You can attach new operations to this via
You can attach new operations to this via

1. Paths `await sdk.extendOperationFromPath('./operations/move-build')` - example: `packages/devtools-movement/operations/init.ts`
2. Providing an implementation of the `INewOperation` interface `await sdk.extendOperation(NewOperation)` - example: `examples/oft-aptos-move/scripts/cli.ts`
2 changes: 1 addition & 1 deletion packages/devtools-move/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

1. Supports movement and evm chain side of the layerzero-sdk
2. Uses existing `hardhat.config.ts` and `layerzero.config.ts`
3. Extensible for OFTs and OApps
3. Extensible for OFTs and OApps
38 changes: 38 additions & 0 deletions packages/devtools-move/sdk/oft.ts
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,44 @@ export class OFT {
}
}

setBlocklistPayload(walletAddress: string, block: boolean, oftType: OFTType): InputGenerateTransactionPayloadData {
return {
function: `${this.oft_address}::${oftType}::set_blocklist`,
functionArguments: [walletAddress, block],
}
}

async isBlocklisted(walletAddress: string, oftType: OFTType): Promise<boolean> {
const result = await this.moveVMConnection.view({
payload: {
function: `${this.oft_address}::${oftType}::is_blocklisted`,
functionArguments: [walletAddress],
},
})
return result[0] as boolean
}

setPrimaryFungibleStoreFrozenPayload(
account: string,
frozen: boolean,
oftType: OFTType
): InputGenerateTransactionPayloadData {
return {
function: `${this.oft_address}::${oftType}::set_primary_fungible_store_frozen`,
functionArguments: [account, frozen],
}
}

async isPrimaryFungibleStoreFrozen(account: string, oftType: OFTType): Promise<boolean> {
const result = await this.moveVMConnection.view({
payload: {
function: `${this.oft_address}::${oftType}::is_primary_fungible_store_frozen`,
functionArguments: [account],
},
})
return result[0] as boolean
}

async signSubmitAndWaitForTx(transaction: SimpleTransaction) {
const signedTransaction = await this.moveVMConnection.signAndSubmitTransaction({
signer: this.signer_account,
Expand Down
50 changes: 50 additions & 0 deletions packages/devtools-move/tasks/move/utils/moveVMOftConfigOps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -756,6 +756,56 @@ export function createPermanentlyDisableFungibleStoreFreezingPayload(oft: OFT):
}
}

export async function createSetBlocklistPayload(
oft: OFT,
oftType: OFTType,
walletAddress: string,
block: boolean
): Promise<TransactionPayload | null> {
const isBlockListed = await oft.isBlocklisted(walletAddress, oftType)
if (isBlockListed === block) {
console.log(`Wallet ${walletAddress} is already ${block ? 'blocked' : 'unblocked'}`)
return null
}

const payload = oft.setBlocklistPayload(walletAddress, block, oftType)
diffPrinter(
`Set Blocklist for ${walletAddress} to ${block ? 'blocked' : 'unblocked'}`,
{ block: isBlockListed },
{ block: block }
)

return {
payload: payload,
description: `Set Blocklist for ${walletAddress} to ${block ? 'blocked' : 'unblocked'}`,
}
}

export async function createSetPrimaryFungibleStoreFrozenPayload(
oft: OFT,
oftType: OFTType,
account: string,
frozen: boolean
): Promise<TransactionPayload | null> {
const isFrozen = await oft.isPrimaryFungibleStoreFrozen(account, oftType)
if (isFrozen === frozen) {
console.log(`\n✅ Account ${account} is already ${frozen ? 'frozen' : 'unfrozen'}\n`)
return null
}

const payload = oft.setPrimaryFungibleStoreFrozenPayload(account, frozen, oftType)
diffPrinter(
`Set Primary Fungible Store Frozen for ${account} to ${frozen ? 'frozen' : 'unfrozen'}`,
{ frozen: isFrozen },
{ frozen: frozen }
)

return {
payload: payload,
description: `Set Primary Fungible Store Frozen for ${account} to ${frozen ? 'frozen' : 'unfrozen'}`,
}
}

function createSerializableExecutorConfig(executorConfig: Uln302ExecutorConfig): ExecutorConfig {
return {
max_message_size: executorConfig.maxMessageSize,
Expand Down
Loading
Loading