@alephium/web3 0.41.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/contract/contract.d.ts +8 -95
- package/dist/src/contract/contract.js +11 -544
- package/dist/src/transaction/index.d.ts +1 -0
- package/dist/src/transaction/index.js +1 -0
- package/dist/src/transaction/utils.d.ts +2 -0
- package/dist/src/transaction/utils.js +34 -0
- package/package.json +1 -1
- package/src/contract/contract.ts +15 -783
- package/src/transaction/index.ts +1 -0
- package/src/transaction/utils.ts +38 -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
|
@@ -12,60 +12,11 @@ export type Arguments = NamedVals;
|
|
|
12
12
|
export type Constant = node.Constant;
|
|
13
13
|
export type Enum = node.Enum;
|
|
14
14
|
export declare const StdIdFieldName = "__stdInterfaceId";
|
|
15
|
-
declare enum SourceKind {
|
|
16
|
-
Contract = 0,
|
|
17
|
-
Script = 1,
|
|
18
|
-
AbstractContract = 2,
|
|
19
|
-
Interface = 3,
|
|
20
|
-
Struct = 4
|
|
21
|
-
}
|
|
22
15
|
export type CompilerOptions = node.CompilerOptions & {
|
|
23
16
|
errorOnWarnings: boolean;
|
|
24
17
|
};
|
|
25
18
|
export declare const DEFAULT_NODE_COMPILER_OPTIONS: node.CompilerOptions;
|
|
26
19
|
export declare const DEFAULT_COMPILER_OPTIONS: CompilerOptions;
|
|
27
|
-
declare class TypedMatcher<T extends SourceKind> {
|
|
28
|
-
matcher: RegExp;
|
|
29
|
-
type: T;
|
|
30
|
-
constructor(pattern: string, type: T);
|
|
31
|
-
}
|
|
32
|
-
declare class SourceInfo {
|
|
33
|
-
type: SourceKind;
|
|
34
|
-
name: string;
|
|
35
|
-
contractRelativePath: string;
|
|
36
|
-
sourceCode: string;
|
|
37
|
-
sourceCodeHash: string;
|
|
38
|
-
isExternal: boolean;
|
|
39
|
-
getArtifactPath(artifactsRootDir: string): string;
|
|
40
|
-
constructor(type: SourceKind, name: string, sourceCode: string, sourceCodeHash: string, contractRelativePath: string, isExternal: boolean);
|
|
41
|
-
static from(type: SourceKind, name: string, sourceCode: string, contractRelativePath: string, isExternal: boolean): Promise<SourceInfo>;
|
|
42
|
-
}
|
|
43
|
-
declare class Compiled<T extends Artifact> {
|
|
44
|
-
sourceInfo: SourceInfo;
|
|
45
|
-
artifact: T;
|
|
46
|
-
warnings: string[];
|
|
47
|
-
constructor(sourceInfo: SourceInfo, artifact: T, warnings: string[]);
|
|
48
|
-
}
|
|
49
|
-
type CodeInfo = {
|
|
50
|
-
sourceFile: string;
|
|
51
|
-
sourceCodeHash: string;
|
|
52
|
-
bytecodeDebugPatch: string;
|
|
53
|
-
codeHashDebug: string;
|
|
54
|
-
warnings: string[];
|
|
55
|
-
};
|
|
56
|
-
export declare class ProjectArtifact {
|
|
57
|
-
static readonly artifactFileName = ".project.json";
|
|
58
|
-
fullNodeVersion: string;
|
|
59
|
-
compilerOptionsUsed: node.CompilerOptions;
|
|
60
|
-
infos: Map<string, CodeInfo>;
|
|
61
|
-
static checkCompilerOptionsParameter(compilerOptions: node.CompilerOptions): void;
|
|
62
|
-
constructor(fullNodeVersion: string, compilerOptionsUsed: node.CompilerOptions, infos: Map<string, CodeInfo>);
|
|
63
|
-
static isCodeChanged(current: ProjectArtifact, previous: ProjectArtifact): boolean;
|
|
64
|
-
saveToFile(rootPath: string): Promise<void>;
|
|
65
|
-
getChangedSources(sourceInfos: SourceInfo[]): SourceInfo[];
|
|
66
|
-
needToReCompile(compilerOptions: node.CompilerOptions, fullNodeVersion: string): boolean;
|
|
67
|
-
static from(rootPath: string): Promise<ProjectArtifact | undefined>;
|
|
68
|
-
}
|
|
69
20
|
export declare class Struct {
|
|
70
21
|
name: string;
|
|
71
22
|
fieldNames: string[];
|
|
@@ -76,43 +27,6 @@ export declare class Struct {
|
|
|
76
27
|
static fromStructSig(sig: node.StructSig): Struct;
|
|
77
28
|
toJson(): any;
|
|
78
29
|
}
|
|
79
|
-
export declare class Project {
|
|
80
|
-
sourceInfos: SourceInfo[];
|
|
81
|
-
contracts: Map<string, Compiled<Contract>>;
|
|
82
|
-
scripts: Map<string, Compiled<Script>>;
|
|
83
|
-
structs: Struct[];
|
|
84
|
-
projectArtifact: ProjectArtifact;
|
|
85
|
-
readonly contractsRootDir: string;
|
|
86
|
-
readonly artifactsRootDir: string;
|
|
87
|
-
static currentProject: Project;
|
|
88
|
-
static readonly importRegex: RegExp;
|
|
89
|
-
static readonly abstractContractMatcher: TypedMatcher<SourceKind>;
|
|
90
|
-
static readonly contractMatcher: TypedMatcher<SourceKind.Contract>;
|
|
91
|
-
static readonly interfaceMatcher: TypedMatcher<SourceKind.Interface>;
|
|
92
|
-
static readonly scriptMatcher: TypedMatcher<SourceKind.Script>;
|
|
93
|
-
static readonly structMatcher: TypedMatcher<SourceKind.Struct>;
|
|
94
|
-
static readonly matchers: TypedMatcher<SourceKind>[];
|
|
95
|
-
static buildProjectArtifact(fullNodeVersion: string, sourceInfos: SourceInfo[], contracts: Map<string, Compiled<Contract>>, scripts: Map<string, Compiled<Script>>, compilerOptions: node.CompilerOptions): ProjectArtifact;
|
|
96
|
-
private constructor();
|
|
97
|
-
static checkCompilerWarnings(warnings: string[], errorOnWarnings: boolean): void;
|
|
98
|
-
static contract(name: string): Contract;
|
|
99
|
-
static script(name: string): Script;
|
|
100
|
-
private static loadStructs;
|
|
101
|
-
private saveStructsToFile;
|
|
102
|
-
private saveArtifactsToFile;
|
|
103
|
-
private saveProjectArtifact;
|
|
104
|
-
contractByCodeHash(codeHash: string): Contract;
|
|
105
|
-
private static getCompileResult;
|
|
106
|
-
private static compile;
|
|
107
|
-
private static loadArtifacts;
|
|
108
|
-
private static getImportSourcePath;
|
|
109
|
-
private static handleImports;
|
|
110
|
-
private static loadSourceFile;
|
|
111
|
-
private static loadSourceFiles;
|
|
112
|
-
static readonly DEFAULT_CONTRACTS_DIR = "contracts";
|
|
113
|
-
static readonly DEFAULT_ARTIFACTS_DIR = "artifacts";
|
|
114
|
-
static build(compilerOptionsPartial?: Partial<CompilerOptions>, projectRootDir?: string, contractsRootDir?: string, artifactsRootDir?: string, defaultFullNodeVersion?: string | undefined, skipSaveArtifacts?: boolean): Promise<void>;
|
|
115
|
-
}
|
|
116
30
|
export declare abstract class Artifact {
|
|
117
31
|
readonly version: string;
|
|
118
32
|
readonly name: string;
|
|
@@ -153,18 +67,18 @@ export declare class Contract extends Artifact {
|
|
|
153
67
|
toApiContractStates(states?: ContractState[]): node.ContractState[] | undefined;
|
|
154
68
|
toApiTestContractParams(funcName: string, params: TestContractParams): node.TestContract;
|
|
155
69
|
fromApiContractState(state: node.ContractState): ContractState<Fields>;
|
|
156
|
-
static fromApiContractState(state: node.ContractState, getContractByCodeHash
|
|
70
|
+
static fromApiContractState(state: node.ContractState, getContractByCodeHash: (codeHash: string) => Contract): ContractState;
|
|
157
71
|
static ContractCreatedEventIndex: number;
|
|
158
72
|
static ContractCreatedEvent: EventSig;
|
|
159
73
|
static ContractDestroyedEventIndex: number;
|
|
160
74
|
static ContractDestroyedEvent: EventSig;
|
|
161
|
-
static fromApiEvent(event: node.ContractEventByTxId, codeHash: string | undefined, txId: string, getContractByCodeHash
|
|
162
|
-
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>;
|
|
163
77
|
txParamsForDeployment<P extends Fields>(signer: SignerProvider, params: DeployContractParams<P>): Promise<SignDeployContractTxParams>;
|
|
164
78
|
buildByteCodeToDeploy(initialFields: Fields, isDevnet: boolean): string;
|
|
165
|
-
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[];
|
|
166
80
|
toApiCallContract<T extends Arguments>(params: CallContractParams<T>, groupIndex: number, contractAddress: string, methodIndex: number): node.CallContract;
|
|
167
|
-
fromApiCallContractResult(result: node.CallContractResult, txId: string, methodIndex: number, getContractByCodeHash
|
|
81
|
+
fromApiCallContractResult(result: node.CallContractResult, txId: string, methodIndex: number, getContractByCodeHash: (codeHash: string) => Contract): CallContractResult<unknown>;
|
|
168
82
|
}
|
|
169
83
|
export declare class Script extends Artifact {
|
|
170
84
|
readonly bytecodeTemplate: string;
|
|
@@ -324,7 +238,7 @@ export declare function subscribeEventsFromContract<T extends Fields, M extends
|
|
|
324
238
|
export declare function addStdIdToFields<F extends Fields>(contract: Contract, fields: F): F | (F & {
|
|
325
239
|
__stdInterfaceId: HexString;
|
|
326
240
|
});
|
|
327
|
-
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>>;
|
|
328
242
|
export declare class RalphMap<K extends Val, V extends Val> {
|
|
329
243
|
private readonly parentContract;
|
|
330
244
|
private readonly parentContractId;
|
|
@@ -352,9 +266,8 @@ export declare function subscribeContractDestroyedEvent(options: EventSubscribeO
|
|
|
352
266
|
export declare function decodeEvent<F extends Fields, M extends ContractEvent<F>>(contract: Contract, instance: ContractInstance, event: node.ContractEvent, targetEventIndex: number): M;
|
|
353
267
|
export declare function subscribeContractEvent<F extends Fields, M extends ContractEvent<F>>(contract: Contract, instance: ContractInstance, options: EventSubscribeOptions<M>, eventName: string, fromCount?: number): EventSubscription;
|
|
354
268
|
export declare function subscribeContractEvents(contract: Contract, instance: ContractInstance, options: EventSubscribeOptions<ContractEvent<any>>, fromCount?: number): EventSubscription;
|
|
355
|
-
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
|
|
356
|
-
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>>>;
|
|
357
271
|
export declare function getContractEventsCurrentCount(contractAddress: Address): Promise<number>;
|
|
358
272
|
export declare const getContractIdFromUnsignedTx: (nodeProvider: NodeProvider, unsignedTx: string) => Promise<HexString>;
|
|
359
273
|
export declare const getTokenIdFromUnsignedTx: (nodeProvider: NodeProvider, unsignedTx: string) => Promise<HexString>;
|
|
360
|
-
export {};
|