@alephium/web3 0.8.2-test.3 → 0.9.0-rc.1
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/api-alephium.d.ts +12 -11
- package/dist/src/api/api-alephium.js +1 -1
- package/dist/src/api/api-explorer.d.ts +7 -7
- package/dist/src/api/node-provider.d.ts +16 -1
- package/dist/src/api/node-provider.js +26 -20
- package/dist/src/api/types.d.ts +5 -5
- package/dist/src/api/types.js +5 -9
- package/dist/src/contract/contract.d.ts +25 -21
- package/dist/src/contract/contract.js +70 -52
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.js +1 -0
- package/dist/src/signer/types.d.ts +5 -5
- package/dist/src/token/index.d.ts +1 -0
- package/dist/src/token/index.js +34 -0
- package/dist/src/token/nft.d.ts +10 -0
- package/dist/src/token/nft.js +19 -0
- package/dist/src/transaction/status.d.ts +1 -1
- package/dist/src/utils/subscription.d.ts +2 -2
- package/dist/src/utils/utils.d.ts +3 -3
- package/package.json +37 -36
- package/src/api/api-alephium.ts +2 -1
- package/src/api/node-provider.ts +41 -25
- package/src/api/types.ts +10 -15
- package/src/contract/contract.ts +63 -40
- package/src/index.ts +1 -0
- package/src/token/index.ts +19 -0
- package/src/token/nft.ts +34 -0
- package/std/fungible_token_interface.ral +1 -0
- package/std/nft_collection_interface.ral +24 -3
- package/std/nft_interface.ral +22 -0
- package/jest-config.json +0 -11
|
@@ -43,7 +43,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
43
43
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
44
44
|
};
|
|
45
45
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
46
|
-
exports.getContractEventsCurrentCount = exports.multicallMethods = exports.callMethod = exports.subscribeContractEvents = exports.subscribeContractEvent = exports.decodeEvent = exports.subscribeContractDestroyedEvent = exports.subscribeContractCreatedEvent = exports.fetchContractState = exports.ContractInstance = exports.testMethod = exports.subscribeEventsFromContract = exports.decodeContractDestroyedEvent = exports.decodeContractCreatedEvent = exports.DestroyContractEventAddress = exports.CreateContractEventAddress = exports.ContractFactory = exports.randomTxId = exports.toApiVals = exports.Script = exports.Contract = exports.Artifact = exports.Project = exports.DEFAULT_COMPILER_OPTIONS = exports.DEFAULT_NODE_COMPILER_OPTIONS = void 0;
|
|
46
|
+
exports.getContractEventsCurrentCount = exports.multicallMethods = exports.callMethod = exports.subscribeContractEvents = exports.subscribeContractEvent = exports.decodeEvent = exports.subscribeContractDestroyedEvent = exports.subscribeContractCreatedEvent = exports.fetchContractState = exports.ContractInstance = exports.testMethod = exports.addStdIdToFields = exports.subscribeEventsFromContract = exports.decodeContractDestroyedEvent = exports.decodeContractCreatedEvent = exports.DestroyContractEventAddress = exports.CreateContractEventAddress = exports.ContractFactory = exports.randomTxId = exports.toApiVals = exports.Script = exports.Contract = exports.Artifact = exports.Project = exports.DEFAULT_COMPILER_OPTIONS = exports.DEFAULT_NODE_COMPILER_OPTIONS = exports.StdIdFieldName = void 0;
|
|
47
47
|
const buffer_1 = require("buffer/");
|
|
48
48
|
const crypto_1 = require("crypto");
|
|
49
49
|
const fs_1 = __importDefault(require("fs"));
|
|
@@ -55,6 +55,7 @@ const global_1 = require("../global");
|
|
|
55
55
|
const path = __importStar(require("path"));
|
|
56
56
|
const events_1 = require("./events");
|
|
57
57
|
const constants_1 = require("../constants");
|
|
58
|
+
exports.StdIdFieldName = '__stdInterfaceId';
|
|
58
59
|
var SourceKind;
|
|
59
60
|
(function (SourceKind) {
|
|
60
61
|
SourceKind[SourceKind["Contract"] = 0] = "Contract";
|
|
@@ -90,14 +91,6 @@ function removeParentsPrefix(parts) {
|
|
|
90
91
|
return path.join(...parts.slice(index));
|
|
91
92
|
}
|
|
92
93
|
class SourceInfo {
|
|
93
|
-
constructor(type, name, sourceCode, sourceCodeHash, contractRelativePath, isExternal) {
|
|
94
|
-
this.type = type;
|
|
95
|
-
this.name = name;
|
|
96
|
-
this.sourceCode = sourceCode;
|
|
97
|
-
this.sourceCodeHash = sourceCodeHash;
|
|
98
|
-
this.contractRelativePath = contractRelativePath;
|
|
99
|
-
this.isExternal = isExternal;
|
|
100
|
-
}
|
|
101
94
|
getArtifactPath(artifactsRootDir) {
|
|
102
95
|
if (this.isExternal) {
|
|
103
96
|
const relativePath = removeParentsPrefix(this.contractRelativePath.split(path.sep));
|
|
@@ -106,6 +99,14 @@ class SourceInfo {
|
|
|
106
99
|
}
|
|
107
100
|
return path.join(artifactsRootDir, this.contractRelativePath) + '.json';
|
|
108
101
|
}
|
|
102
|
+
constructor(type, name, sourceCode, sourceCodeHash, contractRelativePath, isExternal) {
|
|
103
|
+
this.type = type;
|
|
104
|
+
this.name = name;
|
|
105
|
+
this.sourceCode = sourceCode;
|
|
106
|
+
this.sourceCodeHash = sourceCodeHash;
|
|
107
|
+
this.contractRelativePath = contractRelativePath;
|
|
108
|
+
this.isExternal = isExternal;
|
|
109
|
+
}
|
|
109
110
|
static async from(type, name, sourceCode, contractRelativePath, isExternal) {
|
|
110
111
|
const sourceCodeHash = await crypto_1.webcrypto.subtle.digest('SHA-256', buffer_1.Buffer.from(sourceCode));
|
|
111
112
|
const sourceCodeHashHex = buffer_1.Buffer.from(sourceCodeHash).toString('hex');
|
|
@@ -120,11 +121,6 @@ class Compiled {
|
|
|
120
121
|
}
|
|
121
122
|
}
|
|
122
123
|
class ProjectArtifact {
|
|
123
|
-
constructor(compilerOptionsUsed, infos) {
|
|
124
|
-
ProjectArtifact.checkCompilerOptionsParameter(compilerOptionsUsed);
|
|
125
|
-
this.compilerOptionsUsed = compilerOptionsUsed;
|
|
126
|
-
this.infos = infos;
|
|
127
|
-
}
|
|
128
124
|
static checkCompilerOptionsParameter(compilerOptions) {
|
|
129
125
|
if (Object.keys(compilerOptions).length != Object.keys(exports.DEFAULT_NODE_COMPILER_OPTIONS).length) {
|
|
130
126
|
throw Error(`Not all compiler options are set: ${compilerOptions}`);
|
|
@@ -134,6 +130,11 @@ class ProjectArtifact {
|
|
|
134
130
|
throw Error(`There are unknown compiler options: ${compilerOptions}`);
|
|
135
131
|
}
|
|
136
132
|
}
|
|
133
|
+
constructor(compilerOptionsUsed, infos) {
|
|
134
|
+
ProjectArtifact.checkCompilerOptionsParameter(compilerOptionsUsed);
|
|
135
|
+
this.compilerOptionsUsed = compilerOptionsUsed;
|
|
136
|
+
this.infos = infos;
|
|
137
|
+
}
|
|
137
138
|
async saveToFile(rootPath) {
|
|
138
139
|
const filepath = path.join(rootPath, ProjectArtifact.artifactFileName);
|
|
139
140
|
const artifact = {
|
|
@@ -177,20 +178,6 @@ class ProjectArtifact {
|
|
|
177
178
|
}
|
|
178
179
|
ProjectArtifact.artifactFileName = '.project.json';
|
|
179
180
|
class Project {
|
|
180
|
-
constructor(contractsRootDir, artifactsRootDir, sourceInfos, contracts, scripts, errorOnWarnings, projectArtifact) {
|
|
181
|
-
this.contractsRootDir = contractsRootDir;
|
|
182
|
-
this.artifactsRootDir = artifactsRootDir;
|
|
183
|
-
this.sourceInfos = sourceInfos;
|
|
184
|
-
this.contracts = contracts;
|
|
185
|
-
this.scripts = scripts;
|
|
186
|
-
this.projectArtifact = projectArtifact;
|
|
187
|
-
if (errorOnWarnings) {
|
|
188
|
-
Project.checkCompilerWarnings([
|
|
189
|
-
...[...contracts.entries()].map((c) => c[1].warnings).flat(),
|
|
190
|
-
...[...scripts.entries()].map((s) => s[1].warnings).flat()
|
|
191
|
-
], errorOnWarnings);
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
181
|
static buildProjectArtifact(sourceInfos, contracts, scripts, compilerOptions) {
|
|
195
182
|
const files = new Map();
|
|
196
183
|
contracts.forEach((c) => {
|
|
@@ -223,6 +210,20 @@ class Project {
|
|
|
223
210
|
});
|
|
224
211
|
return new ProjectArtifact(compilerOptions, files);
|
|
225
212
|
}
|
|
213
|
+
constructor(contractsRootDir, artifactsRootDir, sourceInfos, contracts, scripts, errorOnWarnings, projectArtifact) {
|
|
214
|
+
this.contractsRootDir = contractsRootDir;
|
|
215
|
+
this.artifactsRootDir = artifactsRootDir;
|
|
216
|
+
this.sourceInfos = sourceInfos;
|
|
217
|
+
this.contracts = contracts;
|
|
218
|
+
this.scripts = scripts;
|
|
219
|
+
this.projectArtifact = projectArtifact;
|
|
220
|
+
if (errorOnWarnings) {
|
|
221
|
+
Project.checkCompilerWarnings([
|
|
222
|
+
...[...contracts.entries()].map((c) => c[1].warnings).flat(),
|
|
223
|
+
...[...scripts.entries()].map((s) => s[1].warnings).flat()
|
|
224
|
+
], errorOnWarnings);
|
|
225
|
+
}
|
|
226
|
+
}
|
|
226
227
|
static checkCompilerWarnings(warnings, errorOnWarnings) {
|
|
227
228
|
if (warnings.length !== 0) {
|
|
228
229
|
const prefixPerWarning = ' - ';
|
|
@@ -450,13 +451,14 @@ class Artifact {
|
|
|
450
451
|
}
|
|
451
452
|
exports.Artifact = Artifact;
|
|
452
453
|
class Contract extends Artifact {
|
|
453
|
-
constructor(version, name, bytecode, bytecodeDebugPatch, codeHash, codeHashDebug, fieldsSig, eventsSig, functions) {
|
|
454
|
+
constructor(version, name, bytecode, bytecodeDebugPatch, codeHash, codeHashDebug, fieldsSig, eventsSig, functions, stdInterfaceId) {
|
|
454
455
|
super(version, name, functions);
|
|
455
456
|
this.bytecode = bytecode;
|
|
456
457
|
this.bytecodeDebugPatch = bytecodeDebugPatch;
|
|
457
458
|
this.codeHash = codeHash;
|
|
458
459
|
this.fieldsSig = fieldsSig;
|
|
459
460
|
this.eventsSig = eventsSig;
|
|
461
|
+
this.stdInterfaceId = stdInterfaceId;
|
|
460
462
|
this.bytecodeDebug = ralph.buildDebugBytecode(this.bytecode, this.bytecodeDebugPatch);
|
|
461
463
|
this.codeHashDebug = codeHashDebug;
|
|
462
464
|
}
|
|
@@ -471,11 +473,11 @@ class Contract extends Artifact {
|
|
|
471
473
|
artifact.functions == null) {
|
|
472
474
|
throw Error('The artifact JSON for contract is incomplete');
|
|
473
475
|
}
|
|
474
|
-
const contract = new Contract(artifact.version, artifact.name, artifact.bytecode, bytecodeDebugPatch, artifact.codeHash, codeHashDebug ? codeHashDebug : artifact.codeHash, artifact.fieldsSig, artifact.eventsSig, artifact.functions);
|
|
476
|
+
const contract = new Contract(artifact.version, artifact.name, artifact.bytecode, bytecodeDebugPatch, artifact.codeHash, codeHashDebug ? codeHashDebug : artifact.codeHash, artifact.fieldsSig, artifact.eventsSig, artifact.functions, artifact.stdInterfaceId === null ? undefined : artifact.stdInterfaceId);
|
|
475
477
|
return contract;
|
|
476
478
|
}
|
|
477
479
|
static fromCompileResult(result) {
|
|
478
|
-
return new Contract(result.version, result.name, result.bytecode, result.bytecodeDebugPatch, result.codeHash, result.codeHashDebug, result.fields, result.events, result.functions);
|
|
480
|
+
return new Contract(result.version, result.name, result.bytecode, result.bytecodeDebugPatch, result.codeHash, result.codeHashDebug, result.fields, result.events, result.functions, result.stdInterfaceId);
|
|
479
481
|
}
|
|
480
482
|
// support both 'code.ral' and 'code.ral.json'
|
|
481
483
|
static async fromArtifactFile(path, bytecodeDebugPatch, codeHashDebug) {
|
|
@@ -493,6 +495,9 @@ class Contract extends Artifact {
|
|
|
493
495
|
eventsSig: this.eventsSig,
|
|
494
496
|
functions: this.functions
|
|
495
497
|
};
|
|
498
|
+
if (this.stdInterfaceId !== undefined) {
|
|
499
|
+
object.stdInterfaceId = this.stdInterfaceId;
|
|
500
|
+
}
|
|
496
501
|
return JSON.stringify(object, null, 2);
|
|
497
502
|
}
|
|
498
503
|
toState(fields, asset, address) {
|
|
@@ -585,11 +590,11 @@ class Contract extends Artifact {
|
|
|
585
590
|
let fields;
|
|
586
591
|
let name;
|
|
587
592
|
if (event.eventIndex == Contract.ContractCreatedEventIndex) {
|
|
588
|
-
fields =
|
|
593
|
+
fields = toContractCreatedEventFields(fromApiEventFields(event.fields, Contract.ContractCreatedEvent, true));
|
|
589
594
|
name = Contract.ContractCreatedEvent.name;
|
|
590
595
|
}
|
|
591
596
|
else if (event.eventIndex == Contract.ContractDestroyedEventIndex) {
|
|
592
|
-
fields =
|
|
597
|
+
fields = fromApiEventFields(event.fields, Contract.ContractDestroyedEvent, true);
|
|
593
598
|
name = Contract.ContractDestroyedEvent.name;
|
|
594
599
|
}
|
|
595
600
|
else {
|
|
@@ -627,7 +632,8 @@ class Contract extends Artifact {
|
|
|
627
632
|
};
|
|
628
633
|
}
|
|
629
634
|
async txParamsForDeployment(signer, params) {
|
|
630
|
-
const
|
|
635
|
+
const initialFields = params.initialFields ?? {};
|
|
636
|
+
const bytecode = this.buildByteCodeToDeploy(addStdIdToFields(this, initialFields));
|
|
631
637
|
const selectedAccount = await signer.getSelectedAccount();
|
|
632
638
|
const signerParams = {
|
|
633
639
|
signerAddress: selectedAccount.address,
|
|
@@ -687,10 +693,8 @@ exports.Contract = Contract;
|
|
|
687
693
|
Contract.ContractCreatedEventIndex = -1;
|
|
688
694
|
Contract.ContractCreatedEvent = {
|
|
689
695
|
name: 'ContractCreated',
|
|
690
|
-
fieldNames: ['address'],
|
|
691
|
-
fieldTypes: ['Address']
|
|
692
|
-
optionalFieldNames: ['parentAddress'],
|
|
693
|
-
optionalFieldTypes: ['Address']
|
|
696
|
+
fieldNames: ['address', 'parentAddress', 'stdInterfaceId'],
|
|
697
|
+
fieldTypes: ['Address', 'Address', 'ByteVec']
|
|
694
698
|
};
|
|
695
699
|
Contract.ContractDestroyedEventIndex = -2;
|
|
696
700
|
Contract.ContractDestroyedEvent = {
|
|
@@ -769,11 +773,8 @@ function fromApiFields(immFields, mutFields, fieldsSig) {
|
|
|
769
773
|
});
|
|
770
774
|
return (0, api_1.fromApiVals)(vals, fieldsSig.names, fieldsSig.types);
|
|
771
775
|
}
|
|
772
|
-
function fromApiEventFields(vals, eventSig) {
|
|
773
|
-
return (0, api_1.fromApiVals)(vals, eventSig.fieldNames, eventSig.fieldTypes);
|
|
774
|
-
}
|
|
775
|
-
function fromApiSystemEventFields(vals, systemEventSig) {
|
|
776
|
-
return (0, api_1.fromApiVals)(vals, systemEventSig.fieldNames, systemEventSig.fieldTypes, systemEventSig.optionalFieldNames ?? [], systemEventSig.optionalFieldTypes ?? []);
|
|
776
|
+
function fromApiEventFields(vals, eventSig, systemEvent = false) {
|
|
777
|
+
return (0, api_1.fromApiVals)(vals, eventSig.fieldNames, eventSig.fieldTypes, systemEvent);
|
|
777
778
|
}
|
|
778
779
|
function toApiAsset(asset) {
|
|
779
780
|
return {
|
|
@@ -872,7 +873,10 @@ class ContractFactory {
|
|
|
872
873
|
this.contract = contract;
|
|
873
874
|
}
|
|
874
875
|
async deploy(signer, deployParams) {
|
|
875
|
-
const signerParams = await this.contract.txParamsForDeployment(signer,
|
|
876
|
+
const signerParams = await this.contract.txParamsForDeployment(signer, {
|
|
877
|
+
...deployParams,
|
|
878
|
+
initialFields: addStdIdToFields(this.contract, deployParams.initialFields)
|
|
879
|
+
});
|
|
876
880
|
const result = await signer.signAndSubmitDeployContractTx(signerParams);
|
|
877
881
|
return {
|
|
878
882
|
...result,
|
|
@@ -885,7 +889,7 @@ class ContractFactory {
|
|
|
885
889
|
alphAmount: asset?.alphAmount ?? constants_1.ONE_ALPH,
|
|
886
890
|
tokens: asset?.tokens
|
|
887
891
|
};
|
|
888
|
-
return this.contract.toState(initFields, newAsset, address);
|
|
892
|
+
return this.contract.toState(addStdIdToFields(this.contract, initFields), newAsset, address);
|
|
889
893
|
}
|
|
890
894
|
}
|
|
891
895
|
exports.ContractFactory = ContractFactory;
|
|
@@ -896,11 +900,20 @@ function specialContractAddress(n) {
|
|
|
896
900
|
}
|
|
897
901
|
exports.CreateContractEventAddress = specialContractAddress(-1);
|
|
898
902
|
exports.DestroyContractEventAddress = specialContractAddress(-2);
|
|
899
|
-
function decodeSystemEvent(event,
|
|
903
|
+
function decodeSystemEvent(event, eventSig, eventIndex) {
|
|
900
904
|
if (event.eventIndex !== eventIndex) {
|
|
901
905
|
throw new Error(`Invalid event index: ${event.eventIndex}, expected: ${eventIndex}`);
|
|
902
906
|
}
|
|
903
|
-
return
|
|
907
|
+
return fromApiEventFields(event.fields, eventSig, true);
|
|
908
|
+
}
|
|
909
|
+
function toContractCreatedEventFields(fields) {
|
|
910
|
+
const parentAddress = fields['parentAddress'];
|
|
911
|
+
const stdInterfaceId = fields['stdInterfaceId'];
|
|
912
|
+
return {
|
|
913
|
+
address: fields['address'],
|
|
914
|
+
parentAddress: parentAddress === '' ? undefined : parentAddress,
|
|
915
|
+
stdInterfaceIdGuessed: stdInterfaceId === '' ? undefined : stdInterfaceId
|
|
916
|
+
};
|
|
904
917
|
}
|
|
905
918
|
function decodeContractCreatedEvent(event) {
|
|
906
919
|
const fields = decodeSystemEvent(event, Contract.ContractCreatedEvent, Contract.ContractCreatedEventIndex);
|
|
@@ -909,10 +922,7 @@ function decodeContractCreatedEvent(event) {
|
|
|
909
922
|
txId: event.txId,
|
|
910
923
|
eventIndex: event.eventIndex,
|
|
911
924
|
name: Contract.ContractCreatedEvent.name,
|
|
912
|
-
fields:
|
|
913
|
-
address: fields['address'],
|
|
914
|
-
parentAddress: fields['parentAddress'] === undefined ? undefined : fields['parentAddress']
|
|
915
|
-
}
|
|
925
|
+
fields: toContractCreatedEventFields(fields)
|
|
916
926
|
};
|
|
917
927
|
}
|
|
918
928
|
exports.decodeContractCreatedEvent = decodeContractCreatedEvent;
|
|
@@ -945,12 +955,20 @@ function subscribeEventsFromContract(options, address, eventIndex, decodeFunc, f
|
|
|
945
955
|
return (0, events_1.subscribeToEvents)(opt, address, fromCount);
|
|
946
956
|
}
|
|
947
957
|
exports.subscribeEventsFromContract = subscribeEventsFromContract;
|
|
958
|
+
function addStdIdToFields(contract, fields) {
|
|
959
|
+
const stdInterfaceIdPrefix = '414c5048'; // the hex of 'ALPH'
|
|
960
|
+
return contract.stdInterfaceId === undefined
|
|
961
|
+
? fields
|
|
962
|
+
: { ...fields, __stdInterfaceId: stdInterfaceIdPrefix + contract.stdInterfaceId };
|
|
963
|
+
}
|
|
964
|
+
exports.addStdIdToFields = addStdIdToFields;
|
|
948
965
|
async function testMethod(contract, methodName, params) {
|
|
949
966
|
const txId = params?.txId ?? randomTxId();
|
|
967
|
+
const initialFields = params.initialFields === undefined ? {} : params.initialFields;
|
|
950
968
|
const apiParams = contract.contract.toApiTestContractParams(methodName, {
|
|
951
969
|
...params,
|
|
952
970
|
txId: txId,
|
|
953
|
-
initialFields:
|
|
971
|
+
initialFields: addStdIdToFields(contract.contract, initialFields),
|
|
954
972
|
testArgs: params.testArgs === undefined ? {} : params.testArgs
|
|
955
973
|
});
|
|
956
974
|
const apiResult = await (0, global_1.getCurrentNodeProvider)().contracts.postContractsTestContract(apiParams);
|
package/dist/src/index.d.ts
CHANGED
package/dist/src/index.js
CHANGED
|
@@ -52,6 +52,7 @@ __exportStar(require("./contract"), exports);
|
|
|
52
52
|
__exportStar(require("./signer"), exports);
|
|
53
53
|
__exportStar(require("./utils"), exports);
|
|
54
54
|
__exportStar(require("./transaction"), exports);
|
|
55
|
+
__exportStar(require("./token"), exports);
|
|
55
56
|
__exportStar(require("./constants"), exports);
|
|
56
57
|
exports.web3 = __importStar(require("./global"));
|
|
57
58
|
exports.utils = __importStar(require("./utils"));
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Number256, Token } from '../api';
|
|
2
2
|
import { node } from '../api';
|
|
3
|
-
export
|
|
4
|
-
export
|
|
3
|
+
export type Address = string;
|
|
4
|
+
export type OutputRef = node.OutputRef;
|
|
5
5
|
export interface Destination {
|
|
6
6
|
address: string;
|
|
7
7
|
attoAlphAmount: Number256;
|
|
@@ -9,14 +9,14 @@ export interface Destination {
|
|
|
9
9
|
lockTime?: number;
|
|
10
10
|
message?: string;
|
|
11
11
|
}
|
|
12
|
-
export
|
|
12
|
+
export type KeyType = 'default' | 'bip340-schnorr';
|
|
13
13
|
export interface Account {
|
|
14
14
|
keyType: KeyType;
|
|
15
15
|
address: string;
|
|
16
16
|
group: number;
|
|
17
17
|
publicKey: string;
|
|
18
18
|
}
|
|
19
|
-
export
|
|
19
|
+
export type SignerAddress = {
|
|
20
20
|
signerAddress: string;
|
|
21
21
|
signerKeyType?: KeyType;
|
|
22
22
|
};
|
|
@@ -88,7 +88,7 @@ export interface SignUnsignedTxResult {
|
|
|
88
88
|
gasAmount: number;
|
|
89
89
|
gasPrice: Number256;
|
|
90
90
|
}
|
|
91
|
-
export
|
|
91
|
+
export type MessageHasher = 'alephium' | 'sha256' | 'blake2b' | 'identity';
|
|
92
92
|
export interface SignMessageParams {
|
|
93
93
|
signerAddress: string;
|
|
94
94
|
signerKeyType?: KeyType;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './nft';
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
Copyright 2018 - 2022 The Alephium Authors
|
|
4
|
+
This file is part of the alephium project.
|
|
5
|
+
|
|
6
|
+
The library is free software: you can redistribute it and/or modify
|
|
7
|
+
it under the terms of the GNU Lesser General Public License as published by
|
|
8
|
+
the Free Software Foundation, either version 3 of the License, or
|
|
9
|
+
(at your option) any later version.
|
|
10
|
+
|
|
11
|
+
The library is distributed in the hope that it will be useful,
|
|
12
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
13
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
14
|
+
GNU Lesser General Public License for more details.
|
|
15
|
+
|
|
16
|
+
You should have received a copy of the GNU Lesser General Public License
|
|
17
|
+
along with the library. If not, see <http://www.gnu.org/licenses/>.
|
|
18
|
+
*/
|
|
19
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
20
|
+
if (k2 === undefined) k2 = k;
|
|
21
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
22
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
23
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
24
|
+
}
|
|
25
|
+
Object.defineProperty(o, k2, desc);
|
|
26
|
+
}) : (function(o, m, k, k2) {
|
|
27
|
+
if (k2 === undefined) k2 = k;
|
|
28
|
+
o[k2] = m[k];
|
|
29
|
+
}));
|
|
30
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
31
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
32
|
+
};
|
|
33
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
34
|
+
__exportStar(require("./nft"), exports);
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
Copyright 2018 - 2022 The Alephium Authors
|
|
4
|
+
This file is part of the alephium project.
|
|
5
|
+
|
|
6
|
+
The library is free software: you can redistribute it and/or modify
|
|
7
|
+
it under the terms of the GNU Lesser General Public License as published by
|
|
8
|
+
the Free Software Foundation, either version 3 of the License, or
|
|
9
|
+
(at your option) any later version.
|
|
10
|
+
|
|
11
|
+
The library is distributed in the hope that it will be useful,
|
|
12
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
13
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
14
|
+
GNU Lesser General Public License for more details.
|
|
15
|
+
|
|
16
|
+
You should have received a copy of the GNU Lesser General Public License
|
|
17
|
+
along with the library. If not, see <http://www.gnu.org/licenses/>.
|
|
18
|
+
*/
|
|
19
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { node } from '../api';
|
|
2
2
|
import { Subscription, SubscribeOptions } from '../utils';
|
|
3
|
-
export
|
|
3
|
+
export type TxStatus = node.TxStatus;
|
|
4
4
|
export declare class TxStatusSubscription extends Subscription<TxStatus> {
|
|
5
5
|
readonly txId: string;
|
|
6
6
|
readonly fromGroup?: number;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import EventEmitter from 'eventemitter3';
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
type MessageCallback<Message> = (message: Message) => Promise<void>;
|
|
3
|
+
type ErrorCallback<Message> = (error: any, subscription: Subscription<Message>) => Promise<void>;
|
|
4
4
|
export interface SubscribeOptions<Message> {
|
|
5
5
|
pollingInterval: number;
|
|
6
6
|
messageCallback: MessageCallback<Message>;
|
|
@@ -29,12 +29,12 @@ export declare function blockChainIndex(blockHash: HexString): {
|
|
|
29
29
|
export declare function stringToHex(str: string): string;
|
|
30
30
|
export declare function hexToString(str: string): string;
|
|
31
31
|
export declare function sleep(ms: number): Promise<void>;
|
|
32
|
-
|
|
33
|
-
export
|
|
32
|
+
type _Eq<X, Y> = (<T>() => T extends X ? 1 : 2) extends <T>() => T extends Y ? 1 : 2 ? true : false;
|
|
33
|
+
export type Eq<X, Y> = _Eq<{
|
|
34
34
|
[P in keyof X]: X[P];
|
|
35
35
|
}, {
|
|
36
36
|
[P in keyof Y]: Y[P];
|
|
37
37
|
}>;
|
|
38
38
|
export declare function assertType<T extends true>(): void;
|
|
39
|
-
export
|
|
39
|
+
export type Optional<T, K extends keyof T> = Pick<Partial<T>, K> & Omit<T, K>;
|
|
40
40
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alephium/web3",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0-rc.1",
|
|
4
4
|
"description": "A JS/TS library to interact with the Alephium platform",
|
|
5
5
|
"license": "GPL",
|
|
6
6
|
"main": "dist/src/index.js",
|
|
@@ -27,70 +27,71 @@
|
|
|
27
27
|
},
|
|
28
28
|
"author": "Alephium dev <dev@alephium.org>",
|
|
29
29
|
"config": {
|
|
30
|
-
"alephium_version": "2.0
|
|
31
|
-
"explorer_backend_version": "1.13.
|
|
32
|
-
},
|
|
33
|
-
"scripts": {
|
|
34
|
-
"build": "rm -rf dist/* && npx tsc --build . && webpack",
|
|
35
|
-
"test": "jest -i --config ./jest-config.json",
|
|
36
|
-
"update-schemas": "npm run update-schema:alephium && npm run update-schema:explorer",
|
|
37
|
-
"update-schema:alephium": "npx swagger-typescript-api --disable-throw-on-error -t ./configs -o ./src/api -n api-alephium.ts -p https://raw.githubusercontent.com/alephium/alephium/v${npm_package_config_alephium_version}/api/src/main/resources/openapi.json",
|
|
38
|
-
"update-schema:explorer": "npx swagger-typescript-api --disable-throw-on-error -t ./configs -o ./src/api -n api-explorer.ts -p https://raw.githubusercontent.com/alephium/explorer-backend/v${npm_package_config_explorer_backend_version}/app/src/main/resources/explorer-backend-openapi.json",
|
|
39
|
-
"check-versions": "node scripts/check-versions.js ${npm_package_config_alephium_version} ${npm_package_config_explorer_backend_version}"
|
|
30
|
+
"alephium_version": "2.1.0",
|
|
31
|
+
"explorer_backend_version": "1.13.4"
|
|
40
32
|
},
|
|
41
33
|
"type": "commonjs",
|
|
42
34
|
"dependencies": {
|
|
43
35
|
"@noble/secp256k1": "1.7.1",
|
|
44
36
|
"async-sema": "^3.1.1",
|
|
45
37
|
"base-x": "4.0.0",
|
|
46
|
-
"bignumber.js": "^9.
|
|
38
|
+
"bignumber.js": "^9.1.1",
|
|
47
39
|
"blakejs": "1.2.1",
|
|
40
|
+
"bn.js": "5.2.1",
|
|
48
41
|
"buffer": "^6.0.3",
|
|
49
42
|
"cross-fetch": "^3.1.5",
|
|
50
43
|
"elliptic": "6.5.4",
|
|
51
44
|
"eventemitter3": "^4.0.7"
|
|
52
45
|
},
|
|
53
46
|
"devDependencies": {
|
|
54
|
-
"@babel/eslint-parser": "^7.
|
|
55
|
-
"@types/elliptic": "^6.4.
|
|
56
|
-
"@types/find-up": "^2.1.
|
|
47
|
+
"@babel/eslint-parser": "^7.21.3",
|
|
48
|
+
"@types/elliptic": "^6.4.14",
|
|
49
|
+
"@types/find-up": "^2.1.1",
|
|
57
50
|
"@types/fs-extra": "^9.0.13",
|
|
58
|
-
"@types/jest": "^27.5.
|
|
51
|
+
"@types/jest": "^27.5.2",
|
|
59
52
|
"@types/mock-fs": "^4.13.1",
|
|
60
|
-
"@types/node": "^16.
|
|
53
|
+
"@types/node": "^16.18.23",
|
|
61
54
|
"@types/rewire": "^2.5.28",
|
|
62
|
-
"@typescript-eslint/eslint-plugin": "^
|
|
63
|
-
"@typescript-eslint/parser": "^
|
|
55
|
+
"@typescript-eslint/eslint-plugin": "^5.57.0",
|
|
56
|
+
"@typescript-eslint/parser": "^5.57.0",
|
|
64
57
|
"clean-webpack-plugin": "4.0.0",
|
|
65
58
|
"crypto-browserify": "^3.12.0",
|
|
66
|
-
"eslint": "^
|
|
67
|
-
"eslint-config-prettier": "^8.
|
|
59
|
+
"eslint": "^8.37.0",
|
|
60
|
+
"eslint-config-prettier": "^8.8.0",
|
|
68
61
|
"eslint-plugin-header": "^3.1.1",
|
|
69
|
-
"eslint-plugin-prettier": "^4.
|
|
62
|
+
"eslint-plugin-prettier": "^4.2.1",
|
|
70
63
|
"eslint-plugin-security": "1.4.0",
|
|
71
64
|
"html-webpack-plugin": "5.5.0",
|
|
72
|
-
"jest": "^28.1.
|
|
73
|
-
"jest-localstorage-mock": "^2.4.
|
|
74
|
-
"jest-websocket-mock": "^2.
|
|
75
|
-
"mock-fs": "^5.
|
|
76
|
-
"mock-socket": "^9.
|
|
65
|
+
"jest": "^28.1.3",
|
|
66
|
+
"jest-localstorage-mock": "^2.4.26",
|
|
67
|
+
"jest-websocket-mock": "^2.4.0",
|
|
68
|
+
"mock-fs": "^5.2.0",
|
|
69
|
+
"mock-socket": "^9.2.1",
|
|
77
70
|
"path-browserify": "^1.0.1",
|
|
78
|
-
"prettier": "^2.
|
|
71
|
+
"prettier": "^2.8.7",
|
|
79
72
|
"process": "^0.11.10",
|
|
80
73
|
"rewire": "^6.0.0",
|
|
81
74
|
"shelljs": "^0.8.5",
|
|
82
75
|
"stream-browserify": "^3.0.0",
|
|
83
76
|
"swagger-typescript-api": "12.0.3",
|
|
84
|
-
"terser-webpack-plugin": "^5.3.
|
|
85
|
-
"ts-jest": "^28.0.
|
|
86
|
-
"ts-node": "^10.
|
|
87
|
-
"tslib": "^2.
|
|
88
|
-
"typescript": "^4.
|
|
89
|
-
"webpack": "^5.
|
|
90
|
-
"webpack-cli": "^4.
|
|
77
|
+
"terser-webpack-plugin": "^5.3.7",
|
|
78
|
+
"ts-jest": "^28.0.8",
|
|
79
|
+
"ts-node": "^10.9.1",
|
|
80
|
+
"tslib": "^2.5.0",
|
|
81
|
+
"typescript": "^4.9.5",
|
|
82
|
+
"webpack": "^5.77.0",
|
|
83
|
+
"webpack-cli": "^4.10.0"
|
|
91
84
|
},
|
|
92
85
|
"engines": {
|
|
93
86
|
"node": ">=16.0.0",
|
|
94
87
|
"npm": ">=7.0.0"
|
|
88
|
+
},
|
|
89
|
+
"scripts": {
|
|
90
|
+
"build": "rm -rf dist/* && npx tsc --build . && webpack",
|
|
91
|
+
"test": "jest -i --config ./jest-config.json",
|
|
92
|
+
"update-schemas": "npm run update-schema:alephium && npm run update-schema:explorer",
|
|
93
|
+
"update-schema:alephium": "npx swagger-typescript-api --disable-throw-on-error -t ./configs -o ./src/api -n api-alephium.ts -p https://raw.githubusercontent.com/alephium/alephium/v${npm_package_config_alephium_version}/api/src/main/resources/openapi.json",
|
|
94
|
+
"update-schema:explorer": "npx swagger-typescript-api --disable-throw-on-error -t ./configs -o ./src/api -n api-explorer.ts -p https://raw.githubusercontent.com/alephium/explorer-backend/v${npm_package_config_explorer_backend_version}/app/src/main/resources/explorer-backend-openapi.json",
|
|
95
|
+
"check-versions": "node scripts/check-versions.js ${npm_package_config_alephium_version} ${npm_package_config_explorer_backend_version}"
|
|
95
96
|
}
|
|
96
|
-
}
|
|
97
|
+
}
|
package/src/api/api-alephium.ts
CHANGED
|
@@ -379,6 +379,7 @@ export interface CompileContractResult {
|
|
|
379
379
|
functions: FunctionSig[]
|
|
380
380
|
events: EventSig[]
|
|
381
381
|
warnings: string[]
|
|
382
|
+
stdInterfaceId?: string
|
|
382
383
|
}
|
|
383
384
|
|
|
384
385
|
export interface CompileProjectResult {
|
|
@@ -1216,7 +1217,7 @@ export class HttpClient<SecurityDataType = unknown> {
|
|
|
1216
1217
|
|
|
1217
1218
|
/**
|
|
1218
1219
|
* @title Alephium API
|
|
1219
|
-
* @version 2.0
|
|
1220
|
+
* @version 2.1.0
|
|
1220
1221
|
* @baseUrl ../
|
|
1221
1222
|
*/
|
|
1222
1223
|
export class Api<SecurityDataType extends unknown> extends HttpClient<SecurityDataType> {
|