@dedot/contracts 0.0.1-next.d731b849.13 → 0.1.1-next.066b3f1e.2
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.
- package/cjs/executor/ConstructorQueryExecutor.js +2 -15
- package/cjs/executor/QueryExecutor.js +11 -12
- package/cjs/index.js +0 -1
- package/cjs/utils.js +2 -2
- package/executor/ConstructorQueryExecutor.js +2 -15
- package/executor/Executor.d.ts +2 -2
- package/executor/QueryExecutor.js +11 -12
- package/index.d.ts +0 -1
- package/index.js +0 -1
- package/package.json +6 -6
- package/types/index.d.ts +8 -13
- package/types/shared.d.ts +1 -1
- package/utils.js +2 -2
- package/cjs/errors.js +0 -84
- package/errors.d.ts +0 -33
- package/errors.js +0 -69
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ConstructorQueryExecutor = void 0;
|
|
4
4
|
const utils_1 = require("@dedot/utils");
|
|
5
|
-
const errors_js_1 = require("../errors.js");
|
|
6
5
|
const utils_js_1 = require("../utils.js");
|
|
7
6
|
const Executor_js_1 = require("./Executor.js");
|
|
8
7
|
class ConstructorQueryExecutor extends Executor_js_1.Executor {
|
|
@@ -14,7 +13,7 @@ class ConstructorQueryExecutor extends Executor_js_1.Executor {
|
|
|
14
13
|
doExecute(constructor) {
|
|
15
14
|
const meta = this.#findConstructorMeta(constructor);
|
|
16
15
|
(0, utils_1.assert)(meta, `Constructor message not found: ${constructor}`);
|
|
17
|
-
const callFn =
|
|
16
|
+
const callFn = (...params) => {
|
|
18
17
|
const { args } = meta;
|
|
19
18
|
(0, utils_1.assert)(params.length === args.length + 1, `Expected ${args.length + 1} arguments, got ${params.length}`);
|
|
20
19
|
const callOptions = params[args.length];
|
|
@@ -27,19 +26,7 @@ class ConstructorQueryExecutor extends Executor_js_1.Executor {
|
|
|
27
26
|
type: (0, utils_1.isWasm)(this.code) ? 'Upload' : 'Existing',
|
|
28
27
|
value: this.code,
|
|
29
28
|
};
|
|
30
|
-
|
|
31
|
-
if (raw.result.isErr) {
|
|
32
|
-
throw new errors_js_1.ContractInstantiateDispatchError(raw.result.err, raw);
|
|
33
|
-
}
|
|
34
|
-
const data = this.tryDecode(meta, raw.result.value.result.data);
|
|
35
|
-
if (data.isErr) {
|
|
36
|
-
throw new errors_js_1.ContractInstantiateLangError(data.err, raw);
|
|
37
|
-
}
|
|
38
|
-
return {
|
|
39
|
-
raw,
|
|
40
|
-
data: data.value,
|
|
41
|
-
address: raw.result.value.accountId,
|
|
42
|
-
};
|
|
29
|
+
return this.api.call.contractsApi.instantiate(caller, value, gasLimit, storageDepositLimit, code, bytes, salt);
|
|
43
30
|
};
|
|
44
31
|
callFn.meta = meta;
|
|
45
32
|
return callFn;
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.QueryExecutor = void 0;
|
|
4
4
|
const utils_1 = require("@dedot/utils");
|
|
5
|
-
const errors_js_1 = require("../errors.js");
|
|
6
5
|
const utils_js_1 = require("../utils.js");
|
|
7
6
|
const Executor_js_1 = require("./Executor.js");
|
|
8
7
|
class QueryExecutor extends Executor_js_1.Executor {
|
|
@@ -18,17 +17,17 @@ class QueryExecutor extends Executor_js_1.Executor {
|
|
|
18
17
|
const formattedInputs = args.map((arg, index) => this.tryEncode(arg, params[index]));
|
|
19
18
|
const bytes = (0, utils_1.u8aToHex)((0, utils_1.concatU8a)((0, utils_1.hexToU8a)(meta.selector), ...formattedInputs));
|
|
20
19
|
const raw = await this.api.call.contractsApi.call(caller, this.address, value, gasLimit, storageDepositLimit, bytes);
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
20
|
+
return (raw.result.isOk
|
|
21
|
+
? {
|
|
22
|
+
isOk: true,
|
|
23
|
+
data: this.tryDecode(meta, raw.result.value.data),
|
|
24
|
+
raw,
|
|
25
|
+
}
|
|
26
|
+
: {
|
|
27
|
+
isOk: false,
|
|
28
|
+
err: raw.result.err,
|
|
29
|
+
raw,
|
|
30
|
+
});
|
|
32
31
|
};
|
|
33
32
|
callFn.meta = meta;
|
|
34
33
|
return callFn;
|
package/cjs/index.js
CHANGED
|
@@ -15,7 +15,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./utils.js"), exports);
|
|
18
|
-
__exportStar(require("./errors.js"), exports);
|
|
19
18
|
__exportStar(require("./executor/index.js"), exports);
|
|
20
19
|
__exportStar(require("./types/index.js"), exports);
|
|
21
20
|
__exportStar(require("./TypinkRegistry.js"), exports);
|
package/cjs/utils.js
CHANGED
|
@@ -41,11 +41,11 @@ const normalizeContractTypeDef = (def) => {
|
|
|
41
41
|
else if (def.composite) {
|
|
42
42
|
type = 'Struct';
|
|
43
43
|
value = {
|
|
44
|
-
fields: def.composite.fields
|
|
44
|
+
fields: def.composite.fields?.map((one) => ({
|
|
45
45
|
typeId: one.type,
|
|
46
46
|
name: one.name,
|
|
47
47
|
typeName: one.typeName,
|
|
48
|
-
})),
|
|
48
|
+
})) || [],
|
|
49
49
|
};
|
|
50
50
|
}
|
|
51
51
|
else if (def.primitive) {
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { assert, concatU8a, hexToU8a, isWasm, u8aToHex } from '@dedot/utils';
|
|
2
|
-
import { ContractInstantiateDispatchError, ContractInstantiateLangError } from '../errors.js';
|
|
3
2
|
import { normalizeLabel } from '../utils.js';
|
|
4
3
|
import { Executor } from './Executor.js';
|
|
5
4
|
export class ConstructorQueryExecutor extends Executor {
|
|
@@ -11,7 +10,7 @@ export class ConstructorQueryExecutor extends Executor {
|
|
|
11
10
|
doExecute(constructor) {
|
|
12
11
|
const meta = this.#findConstructorMeta(constructor);
|
|
13
12
|
assert(meta, `Constructor message not found: ${constructor}`);
|
|
14
|
-
const callFn =
|
|
13
|
+
const callFn = (...params) => {
|
|
15
14
|
const { args } = meta;
|
|
16
15
|
assert(params.length === args.length + 1, `Expected ${args.length + 1} arguments, got ${params.length}`);
|
|
17
16
|
const callOptions = params[args.length];
|
|
@@ -24,19 +23,7 @@ export class ConstructorQueryExecutor extends Executor {
|
|
|
24
23
|
type: isWasm(this.code) ? 'Upload' : 'Existing',
|
|
25
24
|
value: this.code,
|
|
26
25
|
};
|
|
27
|
-
|
|
28
|
-
if (raw.result.isErr) {
|
|
29
|
-
throw new ContractInstantiateDispatchError(raw.result.err, raw);
|
|
30
|
-
}
|
|
31
|
-
const data = this.tryDecode(meta, raw.result.value.result.data);
|
|
32
|
-
if (data.isErr) {
|
|
33
|
-
throw new ContractInstantiateLangError(data.err, raw);
|
|
34
|
-
}
|
|
35
|
-
return {
|
|
36
|
-
raw,
|
|
37
|
-
data: data.value,
|
|
38
|
-
address: raw.result.value.accountId,
|
|
39
|
-
};
|
|
26
|
+
return this.api.call.contractsApi.instantiate(caller, value, gasLimit, storageDepositLimit, code, bytes, salt);
|
|
40
27
|
};
|
|
41
28
|
callFn.meta = meta;
|
|
42
29
|
return callFn;
|
package/executor/Executor.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { SubstrateApi } from '@dedot/api/chaintypes';
|
|
|
3
3
|
import { AccountId32 } from '@dedot/codecs';
|
|
4
4
|
import { GenericSubstrateApi, RpcVersion } from '@dedot/types';
|
|
5
5
|
import { TypinkRegistry } from '../TypinkRegistry.js';
|
|
6
|
-
import { ContractMessageArg,
|
|
6
|
+
import { ContractMessageArg, ContractCallMessage } from '../types/index.js';
|
|
7
7
|
import { ContractMetadata } from '../types/index.js';
|
|
8
8
|
export declare abstract class Executor<ChainApi extends GenericSubstrateApi = SubstrateApi[RpcVersion]> {
|
|
9
9
|
#private;
|
|
@@ -14,5 +14,5 @@ export declare abstract class Executor<ChainApi extends GenericSubstrateApi = Su
|
|
|
14
14
|
get registry(): TypinkRegistry;
|
|
15
15
|
abstract doExecute(...paths: string[]): unknown;
|
|
16
16
|
tryEncode(param: ContractMessageArg, value: any): Uint8Array;
|
|
17
|
-
tryDecode(meta:
|
|
17
|
+
tryDecode(meta: ContractCallMessage, raw: any): unknown;
|
|
18
18
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { assert, concatU8a, hexToU8a, u8aToHex } from '@dedot/utils';
|
|
2
|
-
import { ContractDispatchError, ContractLangError } from '../errors.js';
|
|
3
2
|
import { normalizeLabel } from '../utils.js';
|
|
4
3
|
import { Executor } from './Executor.js';
|
|
5
4
|
export class QueryExecutor extends Executor {
|
|
@@ -15,17 +14,17 @@ export class QueryExecutor extends Executor {
|
|
|
15
14
|
const formattedInputs = args.map((arg, index) => this.tryEncode(arg, params[index]));
|
|
16
15
|
const bytes = u8aToHex(concatU8a(hexToU8a(meta.selector), ...formattedInputs));
|
|
17
16
|
const raw = await this.api.call.contractsApi.call(caller, this.address, value, gasLimit, storageDepositLimit, bytes);
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
17
|
+
return (raw.result.isOk
|
|
18
|
+
? {
|
|
19
|
+
isOk: true,
|
|
20
|
+
data: this.tryDecode(meta, raw.result.value.data),
|
|
21
|
+
raw,
|
|
22
|
+
}
|
|
23
|
+
: {
|
|
24
|
+
isOk: false,
|
|
25
|
+
err: raw.result.err,
|
|
26
|
+
raw,
|
|
27
|
+
});
|
|
29
28
|
};
|
|
30
29
|
callFn.meta = meta;
|
|
31
30
|
return callFn;
|
package/index.d.ts
CHANGED
package/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dedot/contracts",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.1.1-next.066b3f1e.2+066b3f1",
|
|
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.
|
|
22
|
-
"@dedot/codecs": "0.
|
|
23
|
-
"@dedot/types": "0.
|
|
24
|
-
"@dedot/utils": "0.
|
|
21
|
+
"@dedot/api": "0.1.1-next.066b3f1e.2+066b3f1",
|
|
22
|
+
"@dedot/codecs": "0.1.1-next.066b3f1e.2+066b3f1",
|
|
23
|
+
"@dedot/types": "0.1.1-next.066b3f1e.2+066b3f1",
|
|
24
|
+
"@dedot/utils": "0.1.1-next.066b3f1e.2+066b3f1"
|
|
25
25
|
},
|
|
26
26
|
"publishConfig": {
|
|
27
27
|
"access": "public",
|
|
28
28
|
"directory": "dist"
|
|
29
29
|
},
|
|
30
30
|
"license": "Apache-2.0",
|
|
31
|
-
"gitHead": "
|
|
31
|
+
"gitHead": "066b3f1e519f03d80f859f9a9ffb93d22de13626",
|
|
32
32
|
"module": "./index.js",
|
|
33
33
|
"types": "./index.d.ts",
|
|
34
34
|
"exports": {
|
package/types/index.d.ts
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import { SubstrateApi } from '@dedot/api/chaintypes';
|
|
2
|
-
import {
|
|
2
|
+
import { AccountId32Like, BytesLike, DispatchError, Weight } from '@dedot/codecs';
|
|
3
3
|
import { AnyFunc, AsyncMethod, GenericSubstrateApi, RpcVersion, VersionedGenericSubstrateApi } from '@dedot/types';
|
|
4
4
|
import { ContractCallMessage, ContractConstructorMessage } from './shared.js';
|
|
5
5
|
import { ContractEventV4, ContractMetadataV4 } from './v4.js';
|
|
6
6
|
import { ContractEventV5, ContractMetadataV5 } from './v5.js';
|
|
7
7
|
export * from './shared.js';
|
|
8
8
|
export type ContractEventMeta = ContractEventV4 | ContractEventV5;
|
|
9
|
-
export type GenericContractCallResult<DecodedData
|
|
9
|
+
export type GenericContractCallResult<DecodedData, ContractResult> = ({
|
|
10
|
+
isOk: true;
|
|
10
11
|
data: DecodedData;
|
|
12
|
+
} | {
|
|
13
|
+
isOk: false;
|
|
14
|
+
err: DispatchError;
|
|
15
|
+
}) & {
|
|
11
16
|
raw: ContractResult;
|
|
12
17
|
};
|
|
13
|
-
export type GenericConstructorCallResult<DecodedData = any, ContractResult = any> = {
|
|
14
|
-
data: DecodedData;
|
|
15
|
-
raw: ContractResult;
|
|
16
|
-
address: AccountId32;
|
|
17
|
-
};
|
|
18
18
|
export type ContractCallResult<ChainApi extends GenericSubstrateApi> = Awaited<ReturnType<ChainApi['call']['contractsApi']['call']>>;
|
|
19
19
|
export type ContractInstantiateResult<ChainApi extends GenericSubstrateApi> = Awaited<ReturnType<ChainApi['call']['contractsApi']['instantiate']>>;
|
|
20
20
|
export type ContractSubmittableExtrinsic<ChainApi extends GenericSubstrateApi> = ReturnType<ChainApi['tx']['contracts']['call']>;
|
|
@@ -47,7 +47,7 @@ export type GenericContractQueryCall<ChainApi extends GenericSubstrateApi, F ext
|
|
|
47
47
|
export type GenericContractTxCall<ChainApi extends GenericSubstrateApi, F extends AnyFunc = (...args: any[]) => ContractSubmittableExtrinsic<ChainApi>> = F & {
|
|
48
48
|
meta: ContractCallMessage;
|
|
49
49
|
};
|
|
50
|
-
export type GenericConstructorQueryCall<ChainApi extends GenericSubstrateApi, F extends AsyncMethod = (...args: any[]) => Promise<
|
|
50
|
+
export type GenericConstructorQueryCall<ChainApi extends GenericSubstrateApi, F extends AsyncMethod = (...args: any[]) => Promise<ContractInstantiateResult<ChainApi>>> = F & {
|
|
51
51
|
meta: ContractConstructorMessage;
|
|
52
52
|
};
|
|
53
53
|
export type GenericConstructorTxCall<ChainApi extends GenericSubstrateApi, F extends AnyFunc = (...args: any[]) => GenericInstantiateSubmittableExtrinsic<ChainApi>> = F & {
|
|
@@ -79,15 +79,10 @@ export interface GenericContractEvent<EventName extends string = string, Data ex
|
|
|
79
79
|
export interface GenericContractEvents<_ extends GenericSubstrateApi> {
|
|
80
80
|
[event: string]: GenericContractEvent;
|
|
81
81
|
}
|
|
82
|
-
export type GenericInkLangError = 'CouldNotReadInput' | any;
|
|
83
82
|
export interface GenericContractApi<Rv extends RpcVersion = RpcVersion, ChainApi extends VersionedGenericSubstrateApi = SubstrateApi> {
|
|
84
83
|
query: GenericContractQuery<ChainApi[Rv]>;
|
|
85
84
|
tx: GenericContractTx<ChainApi[Rv]>;
|
|
86
85
|
constructorQuery: GenericConstructorQuery<ChainApi[Rv]>;
|
|
87
86
|
constructorTx: GenericConstructorTx<ChainApi[Rv]>;
|
|
88
87
|
events: GenericContractEvents<ChainApi[Rv]>;
|
|
89
|
-
types: {
|
|
90
|
-
LangError: GenericInkLangError;
|
|
91
|
-
ChainApi: ChainApi[Rv];
|
|
92
|
-
};
|
|
93
88
|
}
|
package/types/shared.d.ts
CHANGED
package/utils.js
CHANGED
|
@@ -37,11 +37,11 @@ export const normalizeContractTypeDef = (def) => {
|
|
|
37
37
|
else if (def.composite) {
|
|
38
38
|
type = 'Struct';
|
|
39
39
|
value = {
|
|
40
|
-
fields: def.composite.fields
|
|
40
|
+
fields: def.composite.fields?.map((one) => ({
|
|
41
41
|
typeId: one.type,
|
|
42
42
|
name: one.name,
|
|
43
43
|
typeName: one.typeName,
|
|
44
|
-
})),
|
|
44
|
+
})) || [],
|
|
45
45
|
};
|
|
46
46
|
}
|
|
47
47
|
else if (def.primitive) {
|
package/cjs/errors.js
DELETED
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isContractInstantiateLangError = exports.isContractInstantiateDispatchError = exports.isContractInstantiateExecutionError = exports.isContractLangError = exports.isContractDispatchError = exports.isContractExecutionError = exports.ContractLangError = exports.ContractDispatchError = exports.ContractExecutionError = exports.ContractInstantiateLangError = exports.ContractInstantiateDispatchError = exports.ContractInstantiateExecutionError = void 0;
|
|
4
|
-
const utils_1 = require("@dedot/utils");
|
|
5
|
-
class ContractInstantiateExecutionError extends utils_1.DedotError {
|
|
6
|
-
raw;
|
|
7
|
-
constructor(raw) {
|
|
8
|
-
super();
|
|
9
|
-
this.raw = raw;
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
exports.ContractInstantiateExecutionError = ContractInstantiateExecutionError;
|
|
13
|
-
class ContractInstantiateDispatchError extends ContractInstantiateExecutionError {
|
|
14
|
-
err;
|
|
15
|
-
constructor(err, raw) {
|
|
16
|
-
super(raw);
|
|
17
|
-
this.err = err;
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
exports.ContractInstantiateDispatchError = ContractInstantiateDispatchError;
|
|
21
|
-
/*
|
|
22
|
-
* LangError represents an error which comes from the smart contracting language itself
|
|
23
|
-
* Ref: https://use.ink/faq/migrating-from-ink-3-to-4#:~:text=Add%20support%20for,equivalent%20LangError.
|
|
24
|
-
*/
|
|
25
|
-
class ContractInstantiateLangError extends ContractInstantiateExecutionError {
|
|
26
|
-
err;
|
|
27
|
-
constructor(err, raw) {
|
|
28
|
-
super(raw);
|
|
29
|
-
this.err = err;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
exports.ContractInstantiateLangError = ContractInstantiateLangError;
|
|
33
|
-
class ContractExecutionError extends utils_1.DedotError {
|
|
34
|
-
raw;
|
|
35
|
-
constructor(raw) {
|
|
36
|
-
super();
|
|
37
|
-
this.raw = raw;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
exports.ContractExecutionError = ContractExecutionError;
|
|
41
|
-
class ContractDispatchError extends ContractExecutionError {
|
|
42
|
-
err;
|
|
43
|
-
constructor(err, raw) {
|
|
44
|
-
super(raw);
|
|
45
|
-
this.err = err;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
exports.ContractDispatchError = ContractDispatchError;
|
|
49
|
-
/*
|
|
50
|
-
* LangError represents an error which comes from the smart contracting language itself
|
|
51
|
-
* Ref: https://use.ink/faq/migrating-from-ink-3-to-4#:~:text=Add%20support%20for,equivalent%20LangError.
|
|
52
|
-
*/
|
|
53
|
-
class ContractLangError extends ContractExecutionError {
|
|
54
|
-
err;
|
|
55
|
-
constructor(err, raw) {
|
|
56
|
-
super(raw);
|
|
57
|
-
this.err = err;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
exports.ContractLangError = ContractLangError;
|
|
61
|
-
function isContractExecutionError(e) {
|
|
62
|
-
return e instanceof ContractExecutionError;
|
|
63
|
-
}
|
|
64
|
-
exports.isContractExecutionError = isContractExecutionError;
|
|
65
|
-
function isContractDispatchError(e) {
|
|
66
|
-
return e instanceof ContractDispatchError;
|
|
67
|
-
}
|
|
68
|
-
exports.isContractDispatchError = isContractDispatchError;
|
|
69
|
-
function isContractLangError(e) {
|
|
70
|
-
return e instanceof ContractLangError;
|
|
71
|
-
}
|
|
72
|
-
exports.isContractLangError = isContractLangError;
|
|
73
|
-
function isContractInstantiateExecutionError(e) {
|
|
74
|
-
return e instanceof ContractInstantiateExecutionError;
|
|
75
|
-
}
|
|
76
|
-
exports.isContractInstantiateExecutionError = isContractInstantiateExecutionError;
|
|
77
|
-
function isContractInstantiateDispatchError(e) {
|
|
78
|
-
return e instanceof ContractInstantiateDispatchError;
|
|
79
|
-
}
|
|
80
|
-
exports.isContractInstantiateDispatchError = isContractInstantiateDispatchError;
|
|
81
|
-
function isContractInstantiateLangError(e) {
|
|
82
|
-
return e instanceof ContractInstantiateLangError;
|
|
83
|
-
}
|
|
84
|
-
exports.isContractInstantiateLangError = isContractInstantiateLangError;
|
package/errors.d.ts
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { DispatchError } from '@dedot/codecs';
|
|
2
|
-
import { DedotError } from '@dedot/utils';
|
|
3
|
-
import { ContractCallResult, ContractInstantiateResult, GenericContractApi } from './types';
|
|
4
|
-
export declare class ContractInstantiateExecutionError<ContractApi extends GenericContractApi = GenericContractApi> extends DedotError {
|
|
5
|
-
raw: ContractInstantiateResult<ContractApi['types']['ChainApi']>;
|
|
6
|
-
constructor(raw: ContractInstantiateResult<ContractApi['types']['ChainApi']>);
|
|
7
|
-
}
|
|
8
|
-
export declare class ContractInstantiateDispatchError<ContractApi extends GenericContractApi = GenericContractApi> extends ContractInstantiateExecutionError<ContractApi> {
|
|
9
|
-
err: DispatchError;
|
|
10
|
-
constructor(err: DispatchError, raw: ContractInstantiateResult<ContractApi['types']['ChainApi']>);
|
|
11
|
-
}
|
|
12
|
-
export declare class ContractInstantiateLangError<ContractApi extends GenericContractApi = GenericContractApi> extends ContractInstantiateExecutionError<ContractApi> {
|
|
13
|
-
err: ContractApi['types']['LangError'];
|
|
14
|
-
constructor(err: ContractApi['types']['LangError'], raw: ContractInstantiateResult<ContractApi['types']['ChainApi']>);
|
|
15
|
-
}
|
|
16
|
-
export declare class ContractExecutionError<ContractApi extends GenericContractApi = GenericContractApi> extends DedotError {
|
|
17
|
-
raw: ContractCallResult<ContractApi['types']['ChainApi']>;
|
|
18
|
-
constructor(raw: ContractCallResult<ContractApi['types']['ChainApi']>);
|
|
19
|
-
}
|
|
20
|
-
export declare class ContractDispatchError<ContractApi extends GenericContractApi = GenericContractApi> extends ContractExecutionError<ContractApi> {
|
|
21
|
-
err: DispatchError;
|
|
22
|
-
constructor(err: DispatchError, raw: ContractCallResult<ContractApi['types']['ChainApi']>);
|
|
23
|
-
}
|
|
24
|
-
export declare class ContractLangError<ContractApi extends GenericContractApi = GenericContractApi> extends ContractExecutionError<ContractApi> {
|
|
25
|
-
err: ContractApi['types']['LangError'];
|
|
26
|
-
constructor(err: ContractApi['types']['LangError'], raw: ContractCallResult<ContractApi['types']['ChainApi']>);
|
|
27
|
-
}
|
|
28
|
-
export declare function isContractExecutionError<ContractApi extends GenericContractApi = GenericContractApi>(e: Error): e is ContractExecutionError<ContractApi>;
|
|
29
|
-
export declare function isContractDispatchError<ContractApi extends GenericContractApi = GenericContractApi>(e: Error): e is ContractDispatchError<ContractApi>;
|
|
30
|
-
export declare function isContractLangError<ContractApi extends GenericContractApi = GenericContractApi>(e: Error): e is ContractLangError<ContractApi>;
|
|
31
|
-
export declare function isContractInstantiateExecutionError<ContractApi extends GenericContractApi = GenericContractApi>(e: Error): e is ContractInstantiateExecutionError<ContractApi>;
|
|
32
|
-
export declare function isContractInstantiateDispatchError<ContractApi extends GenericContractApi = GenericContractApi>(e: Error): e is ContractInstantiateDispatchError<ContractApi>;
|
|
33
|
-
export declare function isContractInstantiateLangError<ContractApi extends GenericContractApi = GenericContractApi>(e: Error): e is ContractInstantiateLangError<ContractApi>;
|
package/errors.js
DELETED
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import { DedotError } from '@dedot/utils';
|
|
2
|
-
export class ContractInstantiateExecutionError extends DedotError {
|
|
3
|
-
raw;
|
|
4
|
-
constructor(raw) {
|
|
5
|
-
super();
|
|
6
|
-
this.raw = raw;
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
|
-
export class ContractInstantiateDispatchError extends ContractInstantiateExecutionError {
|
|
10
|
-
err;
|
|
11
|
-
constructor(err, raw) {
|
|
12
|
-
super(raw);
|
|
13
|
-
this.err = err;
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
/*
|
|
17
|
-
* LangError represents an error which comes from the smart contracting language itself
|
|
18
|
-
* Ref: https://use.ink/faq/migrating-from-ink-3-to-4#:~:text=Add%20support%20for,equivalent%20LangError.
|
|
19
|
-
*/
|
|
20
|
-
export class ContractInstantiateLangError extends ContractInstantiateExecutionError {
|
|
21
|
-
err;
|
|
22
|
-
constructor(err, raw) {
|
|
23
|
-
super(raw);
|
|
24
|
-
this.err = err;
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
export class ContractExecutionError extends DedotError {
|
|
28
|
-
raw;
|
|
29
|
-
constructor(raw) {
|
|
30
|
-
super();
|
|
31
|
-
this.raw = raw;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
export class ContractDispatchError extends ContractExecutionError {
|
|
35
|
-
err;
|
|
36
|
-
constructor(err, raw) {
|
|
37
|
-
super(raw);
|
|
38
|
-
this.err = err;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
/*
|
|
42
|
-
* LangError represents an error which comes from the smart contracting language itself
|
|
43
|
-
* Ref: https://use.ink/faq/migrating-from-ink-3-to-4#:~:text=Add%20support%20for,equivalent%20LangError.
|
|
44
|
-
*/
|
|
45
|
-
export class ContractLangError extends ContractExecutionError {
|
|
46
|
-
err;
|
|
47
|
-
constructor(err, raw) {
|
|
48
|
-
super(raw);
|
|
49
|
-
this.err = err;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
export function isContractExecutionError(e) {
|
|
53
|
-
return e instanceof ContractExecutionError;
|
|
54
|
-
}
|
|
55
|
-
export function isContractDispatchError(e) {
|
|
56
|
-
return e instanceof ContractDispatchError;
|
|
57
|
-
}
|
|
58
|
-
export function isContractLangError(e) {
|
|
59
|
-
return e instanceof ContractLangError;
|
|
60
|
-
}
|
|
61
|
-
export function isContractInstantiateExecutionError(e) {
|
|
62
|
-
return e instanceof ContractInstantiateExecutionError;
|
|
63
|
-
}
|
|
64
|
-
export function isContractInstantiateDispatchError(e) {
|
|
65
|
-
return e instanceof ContractInstantiateDispatchError;
|
|
66
|
-
}
|
|
67
|
-
export function isContractInstantiateLangError(e) {
|
|
68
|
-
return e instanceof ContractInstantiateLangError;
|
|
69
|
-
}
|