@dedot/contracts 0.3.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -18,9 +18,9 @@ class ConstructorQueryExecutor extends Executor_js_1.Executor {
18
18
  const { args } = meta;
19
19
  (0, utils_1.assert)(params.length === args.length + 1, `Expected ${args.length + 1} arguments, got ${params.length}`);
20
20
  const callOptions = params[args.length];
21
- const { caller, value = 0n, gasLimit, storageDepositLimit, salt } = callOptions;
21
+ const { caller, value = 0n, gasLimit, storageDepositLimit, salt = '0x' } = callOptions;
22
22
  (0, utils_1.assert)(caller, 'Expected a valid caller address in ConstructorCallOptions');
23
- (0, utils_1.assert)(salt, 'Expected a salt in ConstructorCallOptions');
23
+ (0, utils_1.assertFalse)((0, utils_1.isNull)(salt) || (0, utils_1.isUndefined)(salt), 'Expected a salt in ConstructorCallOptions');
24
24
  const formattedInputs = args.map((arg, index) => this.tryEncode(arg, params[index]));
25
25
  const bytes = (0, utils_1.u8aToHex)((0, utils_1.concatU8a)((0, utils_1.hexToU8a)(meta.selector), ...formattedInputs));
26
26
  const code = {
@@ -17,9 +17,9 @@ class ConstructorTxExecutor extends Executor_js_1.Executor {
17
17
  const { args } = meta;
18
18
  (0, utils_1.assert)(params.length === args.length + 1, `Expected ${args.length + 1} arguments, got ${params.length}`);
19
19
  const txCallOptions = params[args.length];
20
- const { value = 0n, gasLimit, storageDepositLimit, salt } = txCallOptions;
20
+ const { value = 0n, gasLimit, storageDepositLimit, salt = '0x' } = txCallOptions;
21
21
  (0, utils_1.assert)(gasLimit, 'Expected a gas limit in ConstructorTxOptions');
22
- (0, utils_1.assert)(salt, 'Expected a salt in ConstructorTxOptions');
22
+ (0, utils_1.assertFalse)((0, utils_1.isNull)(salt) || (0, utils_1.isUndefined)(salt), 'Expected a salt in ConstructorCallOptions');
23
23
  const formattedInputs = args.map((arg, index) => this.tryEncode(arg, params[index]));
24
24
  const bytes = (0, utils_1.u8aToHex)((0, utils_1.concatU8a)((0, utils_1.hexToU8a)(meta.selector), ...formattedInputs));
25
25
  if ((0, utils_1.isWasm)(this.code)) {
@@ -1,4 +1,4 @@
1
- import { assert, concatU8a, hexToU8a, isWasm, u8aToHex } from '@dedot/utils';
1
+ import { assert, assertFalse, concatU8a, hexToU8a, isNull, isUndefined, isWasm, u8aToHex, } from '@dedot/utils';
2
2
  import { ContractInstantiateDispatchError, ContractInstantiateLangError } from '../errors.js';
3
3
  import { normalizeLabel, toReturnFlags } from '../utils.js';
4
4
  import { Executor } from './Executor.js';
@@ -15,9 +15,9 @@ export class ConstructorQueryExecutor extends Executor {
15
15
  const { args } = meta;
16
16
  assert(params.length === args.length + 1, `Expected ${args.length + 1} arguments, got ${params.length}`);
17
17
  const callOptions = params[args.length];
18
- const { caller, value = 0n, gasLimit, storageDepositLimit, salt } = callOptions;
18
+ const { caller, value = 0n, gasLimit, storageDepositLimit, salt = '0x' } = callOptions;
19
19
  assert(caller, 'Expected a valid caller address in ConstructorCallOptions');
20
- assert(salt, 'Expected a salt in ConstructorCallOptions');
20
+ assertFalse(isNull(salt) || isUndefined(salt), 'Expected a salt in ConstructorCallOptions');
21
21
  const formattedInputs = args.map((arg, index) => this.tryEncode(arg, params[index]));
22
22
  const bytes = u8aToHex(concatU8a(hexToU8a(meta.selector), ...formattedInputs));
23
23
  const code = {
@@ -1,4 +1,4 @@
1
- import { assert, concatU8a, hexToU8a, isWasm, u8aToHex } from '@dedot/utils';
1
+ import { assert, assertFalse, concatU8a, hexToU8a, isNull, isUndefined, isWasm, u8aToHex, } from '@dedot/utils';
2
2
  import { normalizeLabel } from '../utils.js';
3
3
  import { Executor } from './Executor.js';
4
4
  export class ConstructorTxExecutor extends Executor {
@@ -14,9 +14,9 @@ export class ConstructorTxExecutor extends Executor {
14
14
  const { args } = meta;
15
15
  assert(params.length === args.length + 1, `Expected ${args.length + 1} arguments, got ${params.length}`);
16
16
  const txCallOptions = params[args.length];
17
- const { value = 0n, gasLimit, storageDepositLimit, salt } = txCallOptions;
17
+ const { value = 0n, gasLimit, storageDepositLimit, salt = '0x' } = txCallOptions;
18
18
  assert(gasLimit, 'Expected a gas limit in ConstructorTxOptions');
19
- assert(salt, 'Expected a salt in ConstructorTxOptions');
19
+ assertFalse(isNull(salt) || isUndefined(salt), 'Expected a salt in ConstructorCallOptions');
20
20
  const formattedInputs = args.map((arg, index) => this.tryEncode(arg, params[index]));
21
21
  const bytes = u8aToHex(concatU8a(hexToU8a(meta.selector), ...formattedInputs));
22
22
  if (isWasm(this.code)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dedot/contracts",
3
- "version": "0.3.0",
3
+ "version": "0.4.0",
4
4
  "description": "Delightful ink! Contract APIs",
5
5
  "author": "Tung Vu <tung@coongcrafts.io>",
6
6
  "homepage": "https://github.com/dedotdev/dedot/tree/main/packages/contracts",
@@ -18,17 +18,17 @@
18
18
  "test": "vitest --watch=false"
19
19
  },
20
20
  "dependencies": {
21
- "@dedot/api": "0.3.0",
22
- "@dedot/codecs": "0.3.0",
23
- "@dedot/types": "0.3.0",
24
- "@dedot/utils": "0.3.0"
21
+ "@dedot/api": "0.4.0",
22
+ "@dedot/codecs": "0.4.0",
23
+ "@dedot/types": "0.4.0",
24
+ "@dedot/utils": "0.4.0"
25
25
  },
26
26
  "publishConfig": {
27
27
  "access": "public",
28
28
  "directory": "dist"
29
29
  },
30
30
  "license": "Apache-2.0",
31
- "gitHead": "40d0f3c7eee292b7615649e6a5d54887bee75fe2",
31
+ "gitHead": "f6271b5c12d8bf909e4b1a186417bf26db504c63",
32
32
  "module": "./index.js",
33
33
  "types": "./index.d.ts",
34
34
  "exports": {
package/types/index.d.ts CHANGED
@@ -35,11 +35,11 @@ export type CallOptions = {
35
35
  storageDepositLimit?: bigint | undefined;
36
36
  };
37
37
  export type ConstructorCallOptions = CallOptions & {
38
- salt: BytesLike;
38
+ salt?: BytesLike;
39
39
  caller: AccountId32Like;
40
40
  };
41
41
  export type ConstructorTxOptions = CallOptions & {
42
- salt: BytesLike;
42
+ salt?: BytesLike;
43
43
  gasLimit: Weight;
44
44
  };
45
45
  export type ContractCallOptions = CallOptions & {