Skip to content
Merged
Show file tree
Hide file tree
Changes from 46 commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
f374613
explore revive + contracts
sinzii May 28, 2025
34e6058
type updates, ensure pallet supports, tx executors, ...
sinzii May 29, 2025
122c52d
add demo script, ensure contract presence
sinzii May 29, 2025
7c926fd
fix specs
sinzii May 29, 2025
b83e86e
fix events
sinzii May 29, 2025
3acd450
Merge branch 'main' into expore-revive
sinzii May 31, 2025
d067f20
fix conflicts
sinzii May 31, 2025
0391a13
fix build failed
sinzii May 31, 2025
81ce634
regenerate types & add TODO
sinzii May 31, 2025
34ece60
update script
sinzii May 31, 2025
d125ccc
fix specs & storage deposit
sinzii May 31, 2025
cbfa28b
fix e2e
sinzii May 31, 2025
578f5c4
fix e2e
sinzii Jun 1, 2025
56476f3
Add utils needed when creating contract address
1cedrus Jun 1, 2025
a91bf64
Validate salt when deploy contract with pallet-revive
1cedrus Jun 1, 2025
545e26e
Add events handler for pallet-revive
1cedrus Jun 1, 2025
b36025f
Add e2e tests
1cedrus Jun 1, 2025
a1e3ed7
Add github action to run e2e-tests
1cedrus Jun 1, 2025
22bd7c6
Use code for wasm and contract_binary
1cedrus Jun 1, 2025
9276e09
Add ink metadata v6
1cedrus Jun 1, 2025
b5bf93f
Fix wrong config github action
1cedrus Jun 1, 2025
2a24487
Add e2e-tests for errors
1cedrus Jun 2, 2025
5b0fdd1
Validate storageLimitDeposit when call tx in pallet-revive
1cedrus Jun 2, 2025
650a276
Resolve e2e-tests errors
1cedrus Jun 2, 2025
fdfe225
Update the validation check of storageDepositLimit
1cedrus Jun 2, 2025
e748851
support contract storage api
sinzii Jun 3, 2025
67661f4
rename name methods
sinzii Jun 3, 2025
18d3012
update types
sinzii Jun 3, 2025
c333765
refactoring
sinzii Jun 3, 2025
db6c11c
refactoring utils
sinzii Jun 3, 2025
e088487
Add unit tests
1cedrus Jun 3, 2025
c6fe9ec
Add contract address validation
1cedrus Jun 3, 2025
45fe343
Add unit tests for create contractAddress utils
1cedrus Jun 3, 2025
3c3ea0a
clean up create2
sinzii Jun 3, 2025
cbe5353
fix imports
sinzii Jun 4, 2025
46f97a2
add generateRandomHex
sinzii Jun 4, 2025
b8bac92
use generateRandomHex
sinzii Jun 4, 2025
12d7795
rename files
sinzii Jun 4, 2025
04d8cc3
validate salt as 32 bytes
sinzii Jun 4, 2025
46573bf
Fix ensure valid contract adddress
1cedrus Jun 3, 2025
de2ad31
Add validation for code hash or code
1cedrus Jun 4, 2025
c64fa22
Refactor code and remove todo!
1cedrus Jun 4, 2025
414eb35
Fix wrong config e2e-tests
1cedrus Jun 4, 2025
9afb896
Resolve error
1cedrus Jun 4, 2025
0da1dc6
Remove parseRawMetadata
1cedrus Jun 4, 2025
270de4e
Refactor code
1cedrus Jun 4, 2025
eab8956
formatting
sinzii Jun 5, 2025
47e0264
refactoring & renaming
sinzii Jun 5, 2025
8e04c7f
rename field & refactoring
sinzii Jun 5, 2025
520f931
rename & refactoring
sinzii Jun 5, 2025
dc690c5
refactoring examples
sinzii Jun 5, 2025
784ed49
fix ts complains
sinzii Jun 5, 2025
db275da
refactoring, move inputData for easy access
sinzii Jun 5, 2025
bbb5fcc
update example script
sinzii Jun 5, 2025
435c709
add example interact with psp22
sinzii Jun 5, 2025
baf274d
inkv6 version check
sinzii Jun 6, 2025
7941279
Merge remote-tracking branch 'origin/main' into feat/pallet-revive-in…
sinzii Jun 6, 2025
3af7d3b
add psp22 v6 example
sinzii Jun 6, 2025
f1371df
use DedotClient
sinzii Jun 6, 2025
fd76873
fix unit tests
sinzii Jun 6, 2025
86ad557
verify event emitted
sinzii Jun 6, 2025
15ec357
update types
sinzii Jun 6, 2025
41bbcc7
fix e2e
sinzii Jun 6, 2025
c924b61
Refactor code
1cedrus Jun 6, 2025
867118d
remove logs
sinzii Jun 6, 2025
7b3b76b
add assertion
sinzii Jun 6, 2025
f4ca517
fix check code & code-hash
sinzii Jun 6, 2025
3d11b65
fix inkv5 examples
sinzii Jun 6, 2025
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
49 changes: 49 additions & 0 deletions .github/workflows/e2e-contracts-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: E2E Contracts API Tests

on:
push:
workflow_dispatch:
merge_group:

jobs:
e2e-tests:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [18.x]

steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'yarn'
- run: yarn install --immutable
- run: yarn build
- name: Download executables
run: |
curl -L -O https://github.com/paritytech/substrate-contracts-node/releases/download/v0.42.0/substrate-contracts-node-linux.tar.gz
tar -xzf substrate-contracts-node-linux.tar.gz
mv ./substrate-contracts-node-linux/substrate-contracts-node ./substrate-contracts-node
chmod +x substrate-contracts-node

curl -L -O https://github.com/use-ink/ink-node/releases/download/v0.43.2/ink-node-linux.tar.gz
tar -xzf ink-node-linux.tar.gz
mv ./ink-node-linux/ink-node ./ink-node
chmod +x ink-node

- name: Spawn networks
run: |
export PATH=$(pwd):$PATH
export RUST_BACKTRACE=full
./ink-node --rpc-port=9955 &
./substrate-contracts-node --dev --rpc-port=9944 &

chmod +x ./e2e/contracts/wait-for-port.sh
./e2e/contracts/wait-for-port.sh 9944 30
./e2e/contracts/wait-for-port.sh 9955 30

- name: Run tests
run: yarn workspace e2e-contracts run e2e:test
15 changes: 15 additions & 0 deletions e2e/contracts/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "e2e-contracts",
"author": "Tung Vu <tung@dedot.dev>",
"private": true,
"type": "module",
"scripts": {
"e2e:test": "npx vitest --watch=false --no-file-parallelism"
},
"dependencies": {
"@dedot/chaintypes": "^0.101.0",
"@polkadot/keyring": "^13.5.1",
"dedot": "workspace:*"
},
"license": "Apache-2.0"
}
7 changes: 7 additions & 0 deletions e2e/contracts/src/contracts/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
## Contracts

### Generate types for `flipper` contracts
```shell
# Run from project's root folder
yarn cli typink -m ./e2e/contracts/src/contracts/flipper_v5.json -o ./e2e/contracts/src/contracts/
```
58 changes: 58 additions & 0 deletions e2e/contracts/src/contracts/flipper/constructor-query.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
// Generated by dedot cli

import type { Hash, Result } from 'dedot/codecs';
import type {
ConstructorCallOptions,
ContractInstantiateResult,
GenericConstructorCallResult,
GenericConstructorQuery,
GenericConstructorQueryCall,
} from 'dedot/contracts';
import type { GenericSubstrateApi } from 'dedot/types';
import type { FlipperFlipperError } from './types.js';

export interface ConstructorQuery<ChainApi extends GenericSubstrateApi> extends GenericConstructorQuery<ChainApi> {
/**
* Creates a new flipper smart contract initialized with the given value.
*
* @param {boolean} initValue
* @param {ConstructorCallOptions} options
*
* @selector 0x9bae9d5e
**/
new: GenericConstructorQueryCall<
ChainApi,
(
initValue: boolean,
options?: ConstructorCallOptions,
) => Promise<GenericConstructorCallResult<[], ContractInstantiateResult<ChainApi>>>
>;

/**
* Creates a new flipper smart contract initialized to `false`.
*
* @param {ConstructorCallOptions} options
*
* @selector 0x61ef7e3e
**/
newDefault: GenericConstructorQueryCall<
ChainApi,
(options?: ConstructorCallOptions) => Promise<GenericConstructorCallResult<[], ContractInstantiateResult<ChainApi>>>
>;

/**
* Creates a new flipper smart contract with the value being calculate using provided seed.
*
* @param {Hash} seed
* @param {ConstructorCallOptions} options
*
* @selector 0x6d4cae81
**/
fromSeed: GenericConstructorQueryCall<
ChainApi,
(
seed: Hash,
options?: ConstructorCallOptions,
) => Promise<GenericConstructorCallResult<Result<[], FlipperFlipperError>, ContractInstantiateResult<ChainApi>>>
>;
}
50 changes: 50 additions & 0 deletions e2e/contracts/src/contracts/flipper/constructor-tx.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
// Generated by dedot cli

import type { Hash } from 'dedot/codecs';
import type {
ConstructorTxOptions,
GenericConstructorTx,
GenericConstructorTxCall,
GenericInstantiateSubmittableExtrinsic,
} from 'dedot/contracts';
import type { GenericSubstrateApi } from 'dedot/types';

export interface ConstructorTx<ChainApi extends GenericSubstrateApi> extends GenericConstructorTx<ChainApi> {
/**
* Creates a new flipper smart contract initialized with the given value.
*
* @param {boolean} initValue
* @param {ConstructorTxOptions} options
*
* @selector 0x9bae9d5e
**/
new: GenericConstructorTxCall<
ChainApi,
(initValue: boolean, options: ConstructorTxOptions) => GenericInstantiateSubmittableExtrinsic<ChainApi>
>;

/**
* Creates a new flipper smart contract initialized to `false`.
*
* @param {ConstructorTxOptions} options
*
* @selector 0x61ef7e3e
**/
newDefault: GenericConstructorTxCall<
ChainApi,
(options: ConstructorTxOptions) => GenericInstantiateSubmittableExtrinsic<ChainApi>
>;

/**
* Creates a new flipper smart contract with the value being calculate using provided seed.
*
* @param {Hash} seed
* @param {ConstructorTxOptions} options
*
* @selector 0x6d4cae81
**/
fromSeed: GenericConstructorTxCall<
ChainApi,
(seed: Hash, options: ConstructorTxOptions) => GenericInstantiateSubmittableExtrinsic<ChainApi>
>;
}
29 changes: 29 additions & 0 deletions e2e/contracts/src/contracts/flipper/events.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// Generated by dedot cli

import type { GenericContractEvent, GenericContractEvents } from 'dedot/contracts';
import type { GenericSubstrateApi } from 'dedot/types';

export interface ContractEvents<ChainApi extends GenericSubstrateApi> extends GenericContractEvents<ChainApi> {
/**
* Emitted when the flip function is called.
*
* @signature_topic: 0x0a39b5ca0b8b3a5172476100ae7b9168b269cc91d5648efe180c75d935d3e886
**/
Flipped: GenericContractEvent<
'Flipped',
{
/**
* The previous state of the flip.
*
* @indexed: false
**/
old: boolean;
/**
* The new state of the flip.
*
* @indexed: false
**/
new: boolean;
}
>;
}
42 changes: 42 additions & 0 deletions e2e/contracts/src/contracts/flipper/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// Generated by dedot cli

import type { SubstrateApi } from 'dedot/chaintypes';
import type { GenericContractApi, WithLazyStorage } from 'dedot/contracts';
import type { RpcVersion, VersionedGenericSubstrateApi } from 'dedot/types';
import { ConstructorQuery } from './constructor-query.js';
import { ConstructorTx } from './constructor-tx.js';
import { ContractEvents } from './events.js';
import { ContractQuery } from './query.js';
import { ContractTx } from './tx.js';
import type { Flipper, InkPrimitivesLangError } from './types.js';

export * from './types.js';

/**
* @name: FlipperContractApi
* @contractName: flipper
* @contractVersion: 5.0.0
* @authors: Parity Technologies <admin@parity.io>
* @language: ink! 5.0.0
**/
export interface FlipperContractApi<
Rv extends RpcVersion = RpcVersion,
ChainApi extends VersionedGenericSubstrateApi = SubstrateApi,
> extends GenericContractApi<Rv, ChainApi> {
query: ContractQuery<ChainApi[Rv]>;
tx: ContractTx<ChainApi[Rv]>;
constructorQuery: ConstructorQuery<ChainApi[Rv]>;
constructorTx: ConstructorTx<ChainApi[Rv]>;
events: ContractEvents<ChainApi[Rv]>;
storage: {
root(): Promise<Flipper>;
lazy(): WithLazyStorage<Flipper>;
};

types: {
RootStorage: Flipper;
LazyStorage: WithLazyStorage<Flipper>;
LangError: InkPrimitivesLangError;
ChainApi: ChainApi[Rv];
};
}
54 changes: 54 additions & 0 deletions e2e/contracts/src/contracts/flipper/query.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
// Generated by dedot cli

import type { Hash, Result } from 'dedot/codecs';
import type {
ContractCallOptions,
ContractCallResult,
GenericContractCallResult,
GenericContractQuery,
GenericContractQueryCall,
} from 'dedot/contracts';
import type { GenericSubstrateApi } from 'dedot/types';
import type { FlipperFlipperError } from './types.js';

export interface ContractQuery<ChainApi extends GenericSubstrateApi> extends GenericContractQuery<ChainApi> {
/**
* Flips the current value, value based on seed.
*
* @param {Hash} seed
* @param {ContractCallOptions} options
*
* @selector 0x847d0968
**/
flipWithSeed: GenericContractQueryCall<
ChainApi,
(
seed: Hash,
options?: ContractCallOptions,
) => Promise<GenericContractCallResult<Result<boolean, FlipperFlipperError>, ContractCallResult<ChainApi>>>
>;

/**
* Flips the current value of the Flipper's boolean.
*
* @param {ContractCallOptions} options
*
* @selector 0x633aa551
**/
flip: GenericContractQueryCall<
ChainApi,
(options?: ContractCallOptions) => Promise<GenericContractCallResult<[], ContractCallResult<ChainApi>>>
>;

/**
* Returns the current value of the Flipper's boolean.
*
* @param {ContractCallOptions} options
*
* @selector 0x2f865bd9
**/
get: GenericContractQueryCall<
ChainApi,
(options?: ContractCallOptions) => Promise<GenericContractCallResult<boolean, ContractCallResult<ChainApi>>>
>;
}
34 changes: 34 additions & 0 deletions e2e/contracts/src/contracts/flipper/tx.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// Generated by dedot cli

import type { Hash } from 'dedot/codecs';
import type {
ContractSubmittableExtrinsic,
ContractTxOptions,
GenericContractTx,
GenericContractTxCall,
} from 'dedot/contracts';
import type { GenericSubstrateApi } from 'dedot/types';

export interface ContractTx<ChainApi extends GenericSubstrateApi> extends GenericContractTx<ChainApi> {
/**
* Flips the current value, value based on seed.
*
* @param {Hash} seed
* @param {ContractTxOptions} options
*
* @selector 0x847d0968
**/
flipWithSeed: GenericContractTxCall<
ChainApi,
(seed: Hash, options: ContractTxOptions) => ContractSubmittableExtrinsic<ChainApi>
>;

/**
* Flips the current value of the Flipper's boolean.
*
* @param {ContractTxOptions} options
*
* @selector 0x633aa551
**/
flip: GenericContractTxCall<ChainApi, (options: ContractTxOptions) => ContractSubmittableExtrinsic<ChainApi>>;
}
9 changes: 9 additions & 0 deletions e2e/contracts/src/contracts/flipper/types.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// Generated by dedot cli

export type Flipper = { value: boolean };

export type InkPrimitivesLangError = 'CouldNotReadInput';

export type FlipperFlipperError = 'ZeroSum';

export type InkEnvNoChainExtension = null;
288 changes: 288 additions & 0 deletions e2e/contracts/src/contracts/flipper_v5.json

Large diffs are not rendered by default.

288 changes: 288 additions & 0 deletions e2e/contracts/src/contracts/flipper_v6.json

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions e2e/contracts/src/global.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { LegacyClient } from 'dedot';

declare global {
var contractsClient: LegacyClient;
var reviveClient: LegacyClient;
}

export {};
25 changes: 25 additions & 0 deletions e2e/contracts/src/setup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { LegacyClient, WsProvider } from 'dedot';
import { afterAll, beforeAll } from 'vitest';
import { devPairs } from './utils';

const CONTRACTS_NODE_ENDPOINT = 'ws://127.0.0.1:9944';
const INK_NODE_ENDPOINT = 'ws://127.0.0.1:9955';

beforeAll(async () => {
console.log(`Connect to ${CONTRACTS_NODE_ENDPOINT}`);
global.contractsClient = await LegacyClient.new(new WsProvider(CONTRACTS_NODE_ENDPOINT));

console.log(`Connect to ${INK_NODE_ENDPOINT}`);
global.reviveClient = await LegacyClient.new(new WsProvider(INK_NODE_ENDPOINT));

const alicePair = devPairs().alice;
await reviveClient.tx.revive.mapAccount().signAndSend(alicePair).untilFinalized();
}, 120_000);

afterAll(async () => {
await global.contractsClient.disconnect();
console.log(`Disconnected from ${CONTRACTS_NODE_ENDPOINT}`);

await global.reviveClient.disconnect();
Comment thread
1cedrus marked this conversation as resolved.
console.log(`Disconnected from ${INK_NODE_ENDPOINT}`);
});
Loading