@alephium/web3 0.40.0 → 0.42.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.
- package/dist/alephium-web3.min.js +1 -1
- package/dist/alephium-web3.min.js.map +1 -1
- package/dist/src/api/node-provider.d.ts +2 -0
- package/dist/src/api/node-provider.js +12 -6
- package/dist/src/api/utils.d.ts +1 -1
- package/dist/src/block/block.d.ts +28 -0
- package/dist/src/block/block.js +131 -0
- package/dist/src/block/index.d.ts +1 -0
- package/dist/src/block/index.js +22 -0
- package/dist/src/codec/contract-output-codec.js +4 -4
- package/dist/src/codec/lockup-script-codec.js +2 -2
- package/dist/src/codec/method-codec.d.ts +3 -1
- package/dist/src/codec/method-codec.js +27 -2
- package/dist/src/codec/script-codec.d.ts +11 -6
- package/dist/src/codec/script-codec.js +13 -2
- package/dist/src/codec/transaction-codec.js +2 -2
- package/dist/src/codec/unlock-script-codec.d.ts +2 -2
- package/dist/src/codec/unsigned-tx-codec.d.ts +2 -2
- package/dist/src/contract/contract.d.ts +23 -101
- package/dist/src/contract/contract.js +52 -538
- package/dist/src/contract/events.d.ts +1 -2
- package/dist/src/contract/events.js +28 -14
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.js +1 -0
- package/dist/src/signer/tx-builder.js +4 -4
- package/dist/src/transaction/index.d.ts +1 -0
- package/dist/src/transaction/index.js +1 -0
- package/dist/src/transaction/status.js +28 -4
- package/dist/src/transaction/utils.d.ts +2 -0
- package/dist/src/transaction/utils.js +34 -0
- package/dist/src/utils/address.js +29 -16
- package/dist/src/utils/exchange.js +25 -15
- package/dist/src/utils/number.d.ts +1 -1
- package/dist/src/utils/sign.js +6 -6
- package/dist/src/utils/subscription.d.ts +4 -4
- package/dist/src/utils/subscription.js +1 -1
- package/package.json +3 -3
- package/src/api/node-provider.ts +8 -1
- package/src/api/utils.ts +1 -1
- package/src/block/block.ts +139 -0
- package/src/block/index.ts +19 -0
- package/src/codec/contract-output-codec.ts +1 -1
- package/src/codec/lockup-script-codec.ts +3 -3
- package/src/codec/method-codec.ts +41 -3
- package/src/codec/script-codec.ts +23 -5
- package/src/codec/transaction-codec.ts +1 -1
- package/src/codec/unlock-script-codec.ts +2 -2
- package/src/codec/unsigned-tx-codec.ts +2 -2
- package/src/contract/contract.ts +72 -779
- package/src/contract/events.ts +6 -18
- package/src/index.ts +1 -0
- package/src/signer/tx-builder.ts +2 -2
- package/src/transaction/index.ts +1 -0
- package/src/transaction/status.ts +4 -4
- package/src/transaction/utils.ts +38 -0
- package/src/utils/address.ts +15 -2
- package/src/utils/exchange.ts +32 -10
- package/src/utils/number.ts +1 -1
- package/src/utils/sign.ts +1 -1
- package/src/utils/subscription.ts +4 -4
- package/std/fungible_token_interface.ral +1 -0
- package/std/nft_collection_interface.ral +1 -0
- package/std/nft_collection_with_royalty_interface.ral +1 -0
- package/std/nft_interface.ral +1 -0
- package/webpack.config.js +0 -1
- package/dist/src/utils/error.d.ts +0 -15
- package/dist/src/utils/error.js +0 -66
- package/src/utils/error.ts +0 -77
|
@@ -2,68 +2,21 @@ import { NamedVals, node, NodeProvider, Number256, Token, Val } from '../api';
|
|
|
2
2
|
import { SignDeployContractTxParams, SignDeployContractTxResult, SignExecuteScriptTxParams, SignerProvider, Address } from '../signer';
|
|
3
3
|
import { Optional, HexString } from '../utils';
|
|
4
4
|
import { EventSubscribeOptions, EventSubscription } from './events';
|
|
5
|
+
import { Method } from '../codec';
|
|
5
6
|
export type FieldsSig = node.FieldsSig;
|
|
6
7
|
export type MapsSig = node.MapsSig;
|
|
7
8
|
export type EventSig = node.EventSig;
|
|
8
|
-
export type FunctionSig = node.FunctionSig
|
|
9
|
+
export type FunctionSig = Omit<node.FunctionSig, 'isPublic' | 'usePreapprovedAssets' | 'useAssetsInContract'>;
|
|
9
10
|
export type Fields = NamedVals;
|
|
10
11
|
export type Arguments = NamedVals;
|
|
11
12
|
export type Constant = node.Constant;
|
|
12
13
|
export type Enum = node.Enum;
|
|
13
14
|
export declare const StdIdFieldName = "__stdInterfaceId";
|
|
14
|
-
declare enum SourceKind {
|
|
15
|
-
Contract = 0,
|
|
16
|
-
Script = 1,
|
|
17
|
-
AbstractContract = 2,
|
|
18
|
-
Interface = 3,
|
|
19
|
-
Struct = 4
|
|
20
|
-
}
|
|
21
15
|
export type CompilerOptions = node.CompilerOptions & {
|
|
22
16
|
errorOnWarnings: boolean;
|
|
23
17
|
};
|
|
24
18
|
export declare const DEFAULT_NODE_COMPILER_OPTIONS: node.CompilerOptions;
|
|
25
19
|
export declare const DEFAULT_COMPILER_OPTIONS: CompilerOptions;
|
|
26
|
-
declare class TypedMatcher<T extends SourceKind> {
|
|
27
|
-
matcher: RegExp;
|
|
28
|
-
type: T;
|
|
29
|
-
constructor(pattern: string, type: T);
|
|
30
|
-
}
|
|
31
|
-
declare class SourceInfo {
|
|
32
|
-
type: SourceKind;
|
|
33
|
-
name: string;
|
|
34
|
-
contractRelativePath: string;
|
|
35
|
-
sourceCode: string;
|
|
36
|
-
sourceCodeHash: string;
|
|
37
|
-
isExternal: boolean;
|
|
38
|
-
getArtifactPath(artifactsRootDir: string): string;
|
|
39
|
-
constructor(type: SourceKind, name: string, sourceCode: string, sourceCodeHash: string, contractRelativePath: string, isExternal: boolean);
|
|
40
|
-
static from(type: SourceKind, name: string, sourceCode: string, contractRelativePath: string, isExternal: boolean): Promise<SourceInfo>;
|
|
41
|
-
}
|
|
42
|
-
declare class Compiled<T extends Artifact> {
|
|
43
|
-
sourceInfo: SourceInfo;
|
|
44
|
-
artifact: T;
|
|
45
|
-
warnings: string[];
|
|
46
|
-
constructor(sourceInfo: SourceInfo, artifact: T, warnings: string[]);
|
|
47
|
-
}
|
|
48
|
-
type CodeInfo = {
|
|
49
|
-
sourceFile: string;
|
|
50
|
-
sourceCodeHash: string;
|
|
51
|
-
bytecodeDebugPatch: string;
|
|
52
|
-
codeHashDebug: string;
|
|
53
|
-
warnings: string[];
|
|
54
|
-
};
|
|
55
|
-
export declare class ProjectArtifact {
|
|
56
|
-
static readonly artifactFileName = ".project.json";
|
|
57
|
-
fullNodeVersion: string;
|
|
58
|
-
compilerOptionsUsed: node.CompilerOptions;
|
|
59
|
-
infos: Map<string, CodeInfo>;
|
|
60
|
-
static checkCompilerOptionsParameter(compilerOptions: node.CompilerOptions): void;
|
|
61
|
-
constructor(fullNodeVersion: string, compilerOptionsUsed: node.CompilerOptions, infos: Map<string, CodeInfo>);
|
|
62
|
-
static isCodeChanged(current: ProjectArtifact, previous: ProjectArtifact): boolean;
|
|
63
|
-
saveToFile(rootPath: string): Promise<void>;
|
|
64
|
-
needToReCompile(compilerOptions: node.CompilerOptions, sourceInfos: SourceInfo[], fullNodeVersion: string): boolean;
|
|
65
|
-
static from(rootPath: string): Promise<ProjectArtifact | undefined>;
|
|
66
|
-
}
|
|
67
20
|
export declare class Struct {
|
|
68
21
|
name: string;
|
|
69
22
|
fieldNames: string[];
|
|
@@ -74,51 +27,12 @@ export declare class Struct {
|
|
|
74
27
|
static fromStructSig(sig: node.StructSig): Struct;
|
|
75
28
|
toJson(): any;
|
|
76
29
|
}
|
|
77
|
-
export declare class Project {
|
|
78
|
-
sourceInfos: SourceInfo[];
|
|
79
|
-
contracts: Map<string, Compiled<Contract>>;
|
|
80
|
-
scripts: Map<string, Compiled<Script>>;
|
|
81
|
-
structs: Struct[];
|
|
82
|
-
projectArtifact: ProjectArtifact;
|
|
83
|
-
readonly contractsRootDir: string;
|
|
84
|
-
readonly artifactsRootDir: string;
|
|
85
|
-
static currentProject: Project;
|
|
86
|
-
static readonly importRegex: RegExp;
|
|
87
|
-
static readonly abstractContractMatcher: TypedMatcher<SourceKind>;
|
|
88
|
-
static readonly contractMatcher: TypedMatcher<SourceKind.Contract>;
|
|
89
|
-
static readonly interfaceMatcher: TypedMatcher<SourceKind.Interface>;
|
|
90
|
-
static readonly scriptMatcher: TypedMatcher<SourceKind.Script>;
|
|
91
|
-
static readonly structMatcher: TypedMatcher<SourceKind.Struct>;
|
|
92
|
-
static readonly matchers: TypedMatcher<SourceKind>[];
|
|
93
|
-
static buildProjectArtifact(fullNodeVersion: string, sourceInfos: SourceInfo[], contracts: Map<string, Compiled<Contract>>, scripts: Map<string, Compiled<Script>>, compilerOptions: node.CompilerOptions): ProjectArtifact;
|
|
94
|
-
private constructor();
|
|
95
|
-
static checkCompilerWarnings(warnings: string[], errorOnWarnings: boolean): void;
|
|
96
|
-
static contract(name: string): Contract;
|
|
97
|
-
static script(name: string): Script;
|
|
98
|
-
private static loadStructs;
|
|
99
|
-
private saveStructsToFile;
|
|
100
|
-
private saveArtifactsToFile;
|
|
101
|
-
contractByCodeHash(codeHash: string): Contract;
|
|
102
|
-
private static getCompileResult;
|
|
103
|
-
private static compile;
|
|
104
|
-
private static loadArtifacts;
|
|
105
|
-
private static getImportSourcePath;
|
|
106
|
-
private static handleImports;
|
|
107
|
-
private static loadSourceFile;
|
|
108
|
-
private static loadSourceFiles;
|
|
109
|
-
static readonly DEFAULT_CONTRACTS_DIR = "contracts";
|
|
110
|
-
static readonly DEFAULT_ARTIFACTS_DIR = "artifacts";
|
|
111
|
-
static build(compilerOptionsPartial?: Partial<CompilerOptions>, projectRootDir?: string, contractsRootDir?: string, artifactsRootDir?: string, defaultFullNodeVersion?: string | undefined): Promise<void>;
|
|
112
|
-
}
|
|
113
30
|
export declare abstract class Artifact {
|
|
114
31
|
readonly version: string;
|
|
115
32
|
readonly name: string;
|
|
116
33
|
readonly functions: FunctionSig[];
|
|
117
34
|
constructor(version: string, name: string, functions: FunctionSig[]);
|
|
118
35
|
abstract buildByteCodeToDeploy(initialFields: Fields, isDevnet: boolean): string;
|
|
119
|
-
publicFunctions(): string[];
|
|
120
|
-
usingPreapprovedAssetsFunctions(): string[];
|
|
121
|
-
usingAssetsInContractFunctions(): string[];
|
|
122
36
|
isDevnet(signer: SignerProvider): Promise<boolean>;
|
|
123
37
|
}
|
|
124
38
|
export declare class Contract extends Artifact {
|
|
@@ -134,7 +48,11 @@ export declare class Contract extends Artifact {
|
|
|
134
48
|
readonly stdInterfaceId?: HexString;
|
|
135
49
|
readonly bytecodeDebug: string;
|
|
136
50
|
readonly codeHashDebug: string;
|
|
51
|
+
readonly decodedMethods: Method[];
|
|
137
52
|
constructor(version: string, name: string, bytecode: string, bytecodeDebugPatch: string, codeHash: string, codeHashDebug: string, fieldsSig: FieldsSig, eventsSig: EventSig[], functions: FunctionSig[], constants: Constant[], enums: Enum[], structs: Struct[], mapsSig?: MapsSig, stdInterfaceId?: HexString);
|
|
53
|
+
publicFunctions(): FunctionSig[];
|
|
54
|
+
usingPreapprovedAssetsFunctions(): FunctionSig[];
|
|
55
|
+
usingAssetsInContractFunctions(): FunctionSig[];
|
|
138
56
|
static fromJson(artifact: any, bytecodeDebugPatch?: string, codeHashDebug?: string, structs?: Struct[]): Contract;
|
|
139
57
|
static fromCompileResult(result: node.CompileContractResult, structs?: Struct[]): Contract;
|
|
140
58
|
static fromArtifactFile(path: string, bytecodeDebugPatch: string, codeHashDebug: string, structs?: Struct[]): Promise<Contract>;
|
|
@@ -149,18 +67,18 @@ export declare class Contract extends Artifact {
|
|
|
149
67
|
toApiContractStates(states?: ContractState[]): node.ContractState[] | undefined;
|
|
150
68
|
toApiTestContractParams(funcName: string, params: TestContractParams): node.TestContract;
|
|
151
69
|
fromApiContractState(state: node.ContractState): ContractState<Fields>;
|
|
152
|
-
static fromApiContractState(state: node.ContractState, getContractByCodeHash
|
|
70
|
+
static fromApiContractState(state: node.ContractState, getContractByCodeHash: (codeHash: string) => Contract): ContractState;
|
|
153
71
|
static ContractCreatedEventIndex: number;
|
|
154
72
|
static ContractCreatedEvent: EventSig;
|
|
155
73
|
static ContractDestroyedEventIndex: number;
|
|
156
74
|
static ContractDestroyedEvent: EventSig;
|
|
157
|
-
static fromApiEvent(event: node.ContractEventByTxId, codeHash: string | undefined, txId: string, getContractByCodeHash
|
|
158
|
-
fromApiTestContractResult(methodName: string, result: node.TestContractResult, txId: string): TestContractResult<unknown>;
|
|
75
|
+
static fromApiEvent(event: node.ContractEventByTxId, codeHash: string | undefined, txId: string, getContractByCodeHash: (codeHash: string) => Contract): ContractEvent;
|
|
76
|
+
fromApiTestContractResult(methodName: string, result: node.TestContractResult, txId: string, getContractByCodeHash: (codeHash: string) => Contract): TestContractResult<unknown>;
|
|
159
77
|
txParamsForDeployment<P extends Fields>(signer: SignerProvider, params: DeployContractParams<P>): Promise<SignDeployContractTxParams>;
|
|
160
78
|
buildByteCodeToDeploy(initialFields: Fields, isDevnet: boolean): string;
|
|
161
|
-
static fromApiEvents(events: node.ContractEventByTxId[], addressToCodeHash: Map<string, string>, txId: string, getContractByCodeHash
|
|
79
|
+
static fromApiEvents(events: node.ContractEventByTxId[], addressToCodeHash: Map<string, string>, txId: string, getContractByCodeHash: (codeHash: string) => Contract): ContractEvent[];
|
|
162
80
|
toApiCallContract<T extends Arguments>(params: CallContractParams<T>, groupIndex: number, contractAddress: string, methodIndex: number): node.CallContract;
|
|
163
|
-
fromApiCallContractResult(result: node.CallContractResult, txId: string, methodIndex: number, getContractByCodeHash
|
|
81
|
+
fromApiCallContractResult(result: node.CallContractResult, txId: string, methodIndex: number, getContractByCodeHash: (codeHash: string) => Contract): CallContractResult<unknown>;
|
|
164
82
|
}
|
|
165
83
|
export declare class Script extends Artifact {
|
|
166
84
|
readonly bytecodeTemplate: string;
|
|
@@ -320,16 +238,22 @@ export declare function subscribeEventsFromContract<T extends Fields, M extends
|
|
|
320
238
|
export declare function addStdIdToFields<F extends Fields>(contract: Contract, fields: F): F | (F & {
|
|
321
239
|
__stdInterfaceId: HexString;
|
|
322
240
|
});
|
|
323
|
-
export declare function testMethod<I extends ContractInstance, F extends Fields, A extends Arguments, R, M extends Record<string, Map<Val, Val>> = Record<string, Map<Val, Val>>>(factory: ContractFactory<I, F>, methodName: string, params: Optional<TestContractParams<F, A, M>, 'testArgs' | 'initialFields'
|
|
241
|
+
export declare function testMethod<I extends ContractInstance, F extends Fields, A extends Arguments, R, M extends Record<string, Map<Val, Val>> = Record<string, Map<Val, Val>>>(factory: ContractFactory<I, F>, methodName: string, params: Optional<TestContractParams<F, A, M>, 'testArgs' | 'initialFields'>, getContractByCodeHash: (codeHash: string) => Contract): Promise<TestContractResult<R, M>>;
|
|
324
242
|
export declare class RalphMap<K extends Val, V extends Val> {
|
|
325
243
|
private readonly parentContract;
|
|
326
|
-
private readonly
|
|
244
|
+
private readonly parentContractId;
|
|
327
245
|
private readonly mapName;
|
|
328
|
-
|
|
246
|
+
private readonly groupIndex;
|
|
247
|
+
constructor(parentContract: Contract, parentContractId: HexString, mapName: string);
|
|
329
248
|
get(key: K): Promise<V | undefined>;
|
|
330
249
|
contains(key: K): Promise<boolean>;
|
|
250
|
+
toJSON(): {
|
|
251
|
+
parentContractId: string;
|
|
252
|
+
mapName: string;
|
|
253
|
+
groupIndex: number;
|
|
254
|
+
};
|
|
331
255
|
}
|
|
332
|
-
export declare function getMapItem<R extends Val>(parentContract: Contract,
|
|
256
|
+
export declare function getMapItem<R extends Val>(parentContract: Contract, parentContractId: HexString, groupIndex: number, mapName: string, key: Val): Promise<R | undefined>;
|
|
333
257
|
export declare abstract class ContractInstance {
|
|
334
258
|
readonly address: Address;
|
|
335
259
|
readonly contractId: string;
|
|
@@ -342,10 +266,8 @@ export declare function subscribeContractDestroyedEvent(options: EventSubscribeO
|
|
|
342
266
|
export declare function decodeEvent<F extends Fields, M extends ContractEvent<F>>(contract: Contract, instance: ContractInstance, event: node.ContractEvent, targetEventIndex: number): M;
|
|
343
267
|
export declare function subscribeContractEvent<F extends Fields, M extends ContractEvent<F>>(contract: Contract, instance: ContractInstance, options: EventSubscribeOptions<M>, eventName: string, fromCount?: number): EventSubscription;
|
|
344
268
|
export declare function subscribeContractEvents(contract: Contract, instance: ContractInstance, options: EventSubscribeOptions<ContractEvent<any>>, fromCount?: number): EventSubscription;
|
|
345
|
-
export declare function callMethod<I extends ContractInstance, F extends Fields, A extends Arguments, R>(contract: ContractFactory<I, F>, instance: ContractInstance, methodName: string, params: Optional<CallContractParams<A>, 'args'>, getContractByCodeHash
|
|
346
|
-
export declare function multicallMethods<I extends ContractInstance, F extends Fields>(contract: ContractFactory<I, F>, instance: ContractInstance, calls: Record<string, Optional<CallContractParams<any>, 'args'>>, getContractByCodeHash
|
|
269
|
+
export declare function callMethod<I extends ContractInstance, F extends Fields, A extends Arguments, R>(contract: ContractFactory<I, F>, instance: ContractInstance, methodName: string, params: Optional<CallContractParams<A>, 'args'>, getContractByCodeHash: (codeHash: string) => Contract): Promise<CallContractResult<R>>;
|
|
270
|
+
export declare function multicallMethods<I extends ContractInstance, F extends Fields>(contract: ContractFactory<I, F>, instance: ContractInstance, calls: Record<string, Optional<CallContractParams<any>, 'args'>>, getContractByCodeHash: (codeHash: string) => Contract): Promise<Record<string, CallContractResult<any>>>;
|
|
347
271
|
export declare function getContractEventsCurrentCount(contractAddress: Address): Promise<number>;
|
|
348
272
|
export declare const getContractIdFromUnsignedTx: (nodeProvider: NodeProvider, unsignedTx: string) => Promise<HexString>;
|
|
349
273
|
export declare const getTokenIdFromUnsignedTx: (nodeProvider: NodeProvider, unsignedTx: string) => Promise<HexString>;
|
|
350
|
-
export declare function tryGetCallResult(result: node.CallContractResult): node.CallContractSucceeded;
|
|
351
|
-
export {};
|