@alephium/web3 0.2.0-rc.37 → 0.2.0-rc.38

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.
@@ -315,6 +315,7 @@ export interface ChangeActiveAddress {
315
315
  address: string;
316
316
  }
317
317
  export interface CompileContractResult {
318
+ version: string;
318
319
  name: string;
319
320
  bytecode: string;
320
321
  bytecodeDebugPatch: string;
@@ -332,6 +333,7 @@ export interface CompileProjectResult {
332
333
  scripts: CompileScriptResult[];
333
334
  }
334
335
  export interface CompileScriptResult {
336
+ version: string;
335
337
  name: string;
336
338
  bytecodeTemplate: string;
337
339
  bytecodeDebugPatch: string;
@@ -1364,6 +1366,18 @@ export declare class Api<SecurityDataType extends unknown> extends HttpClient<Se
1364
1366
  * @request POST:/transactions/decode-unsigned-tx
1365
1367
  */
1366
1368
  postTransactionsDecodeUnsignedTx: (data: DecodeUnsignedTx, params?: RequestParams) => Promise<DecodeUnsignedTxResult>;
1369
+ /**
1370
+ * No description
1371
+ *
1372
+ * @tags Transactions
1373
+ * @name GetTransactionsDetailsTxid
1374
+ * @summary Get transaction details
1375
+ * @request GET:/transactions/details/{txId}
1376
+ */
1377
+ getTransactionsDetailsTxid: (txId: string, query?: {
1378
+ fromGroup?: number;
1379
+ toGroup?: number;
1380
+ }, params?: RequestParams) => Promise<Transaction>;
1367
1381
  /**
1368
1382
  * No description
1369
1383
  *
@@ -856,6 +856,21 @@ class Api extends HttpClient {
856
856
  format: 'json',
857
857
  ...params
858
858
  }).then(utils_1.convertHttpResponse),
859
+ /**
860
+ * No description
861
+ *
862
+ * @tags Transactions
863
+ * @name GetTransactionsDetailsTxid
864
+ * @summary Get transaction details
865
+ * @request GET:/transactions/details/{txId}
866
+ */
867
+ getTransactionsDetailsTxid: (txId, query, params = {}) => this.request({
868
+ path: `/transactions/details/${txId}`,
869
+ method: 'GET',
870
+ query: query,
871
+ format: 'json',
872
+ ...params
873
+ }).then(utils_1.convertHttpResponse),
859
874
  /**
860
875
  * No description
861
876
  *
@@ -85,16 +85,16 @@ class NodeProvider {
85
85
  else {
86
86
  nodeApi = param0;
87
87
  }
88
- this.wallets = nodeApi.wallets;
89
- this.infos = nodeApi.infos;
90
- this.blockflow = nodeApi.blockflow;
91
- this.addresses = nodeApi.addresses;
92
- this.transactions = nodeApi.transactions;
93
- this.contracts = nodeApi.contracts;
94
- this.multisig = nodeApi.multisig;
95
- this.utils = nodeApi.utils;
96
- this.miners = nodeApi.miners;
97
- this.events = nodeApi.events;
88
+ this.wallets = { ...nodeApi.wallets };
89
+ this.infos = { ...nodeApi.infos };
90
+ this.blockflow = { ...nodeApi.blockflow };
91
+ this.addresses = { ...nodeApi.addresses };
92
+ this.transactions = { ...nodeApi.transactions };
93
+ this.contracts = { ...nodeApi.contracts };
94
+ this.multisig = { ...nodeApi.multisig };
95
+ this.utils = { ...nodeApi.utils };
96
+ this.miners = { ...nodeApi.miners };
97
+ this.events = { ...nodeApi.events };
98
98
  }
99
99
  // This can prevent the proxied node provider from being modified
100
100
  static Proxy(nodeProvider) {
@@ -140,16 +140,16 @@ class ExplorerProvider {
140
140
  else {
141
141
  explorerApi = param0;
142
142
  }
143
- this.blocks = explorerApi.blocks;
144
- this.transactions = explorerApi.transactions;
145
- this.transactionByOutputRefKey = explorerApi.transactionByOutputRefKey;
146
- this.addresses = explorerApi.addresses;
147
- this.addressesActive = explorerApi.addressesActive;
148
- this.infos = explorerApi.infos;
149
- this.unconfirmedTransactions = explorerApi.unconfirmedTransactions;
150
- this.tokens = explorerApi.tokens;
151
- this.charts = explorerApi.charts;
152
- this.utils = explorerApi.utils;
143
+ this.blocks = { ...explorerApi.blocks };
144
+ this.transactions = { ...explorerApi.transactions };
145
+ this.transactionByOutputRefKey = { ...explorerApi.transactionByOutputRefKey };
146
+ this.addresses = { ...explorerApi.addresses };
147
+ this.addressesActive = { ...explorerApi.addressesActive };
148
+ this.infos = { ...explorerApi.infos };
149
+ this.unconfirmedTransactions = { ...explorerApi.unconfirmedTransactions };
150
+ this.tokens = { ...explorerApi.tokens };
151
+ this.charts = { ...explorerApi.charts };
152
+ this.utils = { ...explorerApi.utils };
153
153
  }
154
154
  // This can prevent the proxied explorer provider from being modified
155
155
  static Proxy(explorerProvider) {
@@ -83,9 +83,10 @@ export declare class Project {
83
83
  static build(compilerOptionsPartial?: Partial<CompilerOptions>, contractsRootDir?: string, artifactsRootDir?: string): Promise<void>;
84
84
  }
85
85
  export declare abstract class Artifact {
86
+ readonly version: string;
86
87
  readonly name: string;
87
88
  readonly functions: FunctionSig[];
88
- constructor(name: string, functions: FunctionSig[]);
89
+ constructor(version: string, name: string, functions: FunctionSig[]);
89
90
  abstract buildByteCodeToDeploy(initialFields?: Fields): string;
90
91
  publicFunctions(): string[];
91
92
  usingPreapprovedAssetsFunctions(): string[];
@@ -99,7 +100,7 @@ export declare class Contract extends Artifact {
99
100
  readonly eventsSig: EventSig[];
100
101
  readonly bytecodeDebug: string;
101
102
  readonly codeHashDebug: string;
102
- constructor(name: string, bytecode: string, bytecodeDebugPatch: string, codeHash: string, codeHashDebug: string, fieldsSig: FieldsSig, eventsSig: EventSig[], functions: FunctionSig[]);
103
+ constructor(version: string, name: string, bytecode: string, bytecodeDebugPatch: string, codeHash: string, codeHashDebug: string, fieldsSig: FieldsSig, eventsSig: EventSig[], functions: FunctionSig[]);
103
104
  static fromJson(artifact: any, bytecodeDebugPatch?: string, codeHashDebug?: string): Contract;
104
105
  static fromCompileResult(result: node.CompileContractResult): Contract;
105
106
  static fromArtifactFile(path: string, bytecodeDebugPatch: string, codeHashDebug: string): Promise<Contract>;
@@ -129,7 +130,7 @@ export declare class Script extends Artifact {
129
130
  readonly bytecodeTemplate: string;
130
131
  readonly bytecodeDebugPatch: string;
131
132
  readonly fieldsSig: FieldsSig;
132
- constructor(name: string, bytecodeTemplate: string, bytecodeDebugPatch: string, fieldsSig: FieldsSig, functions: FunctionSig[]);
133
+ constructor(version: string, name: string, bytecodeTemplate: string, bytecodeDebugPatch: string, fieldsSig: FieldsSig, functions: FunctionSig[]);
133
134
  static fromCompileResult(result: node.CompileScriptResult): Script;
134
135
  static fromJson(artifact: any, bytecodeDebugPatch?: string): Script;
135
136
  static fromArtifactFile(path: string, bytecodeDebugPatch: string): Promise<Script>;
@@ -375,7 +375,8 @@ Project.matchers = [
375
375
  Project.DEFAULT_CONTRACTS_DIR = 'contracts';
376
376
  Project.DEFAULT_ARTIFACTS_DIR = 'artifacts';
377
377
  class Artifact {
378
- constructor(name, functions) {
378
+ constructor(version, name, functions) {
379
+ this.version = version;
379
380
  this.name = name;
380
381
  this.functions = functions;
381
382
  }
@@ -391,8 +392,8 @@ class Artifact {
391
392
  }
392
393
  exports.Artifact = Artifact;
393
394
  class Contract extends Artifact {
394
- constructor(name, bytecode, bytecodeDebugPatch, codeHash, codeHashDebug, fieldsSig, eventsSig, functions) {
395
- super(name, functions);
395
+ constructor(version, name, bytecode, bytecodeDebugPatch, codeHash, codeHashDebug, fieldsSig, eventsSig, functions) {
396
+ super(version, name, functions);
396
397
  this.bytecode = bytecode;
397
398
  this.bytecodeDebugPatch = bytecodeDebugPatch;
398
399
  this.codeHash = codeHash;
@@ -403,7 +404,8 @@ class Contract extends Artifact {
403
404
  }
404
405
  // TODO: safely parse json
405
406
  static fromJson(artifact, bytecodeDebugPatch = '', codeHashDebug = '') {
406
- if (artifact.name == null ||
407
+ if (artifact.version == null ||
408
+ artifact.name == null ||
407
409
  artifact.bytecode == null ||
408
410
  artifact.codeHash == null ||
409
411
  artifact.fieldsSig == null ||
@@ -411,11 +413,11 @@ class Contract extends Artifact {
411
413
  artifact.functions == null) {
412
414
  throw Error('The artifact JSON for contract is incomplete');
413
415
  }
414
- const contract = new Contract(artifact.name, artifact.bytecode, bytecodeDebugPatch, artifact.codeHash, codeHashDebug ? codeHashDebug : artifact.codeHash, artifact.fieldsSig, artifact.eventsSig, artifact.functions);
416
+ const contract = new Contract(artifact.version, artifact.name, artifact.bytecode, bytecodeDebugPatch, artifact.codeHash, codeHashDebug ? codeHashDebug : artifact.codeHash, artifact.fieldsSig, artifact.eventsSig, artifact.functions);
415
417
  return contract;
416
418
  }
417
419
  static fromCompileResult(result) {
418
- return new Contract(result.name, result.bytecode, result.bytecodeDebugPatch, result.codeHash, result.codeHashDebug, result.fields, result.events, result.functions);
420
+ return new Contract(result.version, result.name, result.bytecode, result.bytecodeDebugPatch, result.codeHash, result.codeHashDebug, result.fields, result.events, result.functions);
419
421
  }
420
422
  // support both 'code.ral' and 'code.ral.json'
421
423
  static async fromArtifactFile(path, bytecodeDebugPatch, codeHashDebug) {
@@ -431,6 +433,7 @@ class Contract extends Artifact {
431
433
  }
432
434
  toString() {
433
435
  const object = {
436
+ version: this.version,
434
437
  name: this.name,
435
438
  bytecode: this.bytecode,
436
439
  codeHash: this.codeHash,
@@ -615,24 +618,25 @@ Contract.ContractDestroyedEvent = {
615
618
  fieldTypes: ['Address']
616
619
  };
617
620
  class Script extends Artifact {
618
- constructor(name, bytecodeTemplate, bytecodeDebugPatch, fieldsSig, functions) {
619
- super(name, functions);
621
+ constructor(version, name, bytecodeTemplate, bytecodeDebugPatch, fieldsSig, functions) {
622
+ super(version, name, functions);
620
623
  this.bytecodeTemplate = bytecodeTemplate;
621
624
  this.bytecodeDebugPatch = bytecodeDebugPatch;
622
625
  this.fieldsSig = fieldsSig;
623
626
  }
624
627
  static fromCompileResult(result) {
625
- return new Script(result.name, result.bytecodeTemplate, result.bytecodeDebugPatch, result.fields, result.functions);
628
+ return new Script(result.version, result.name, result.bytecodeTemplate, result.bytecodeDebugPatch, result.fields, result.functions);
626
629
  }
627
630
  // TODO: safely parse json
628
631
  static fromJson(artifact, bytecodeDebugPatch = '') {
629
- if (artifact.name == null ||
632
+ if (artifact.version == null ||
633
+ artifact.name == null ||
630
634
  artifact.bytecodeTemplate == null ||
631
635
  artifact.fieldsSig == null ||
632
636
  artifact.functions == null) {
633
637
  throw Error('The artifact JSON for script is incomplete');
634
638
  }
635
- return new Script(artifact.name, artifact.bytecodeTemplate, bytecodeDebugPatch, artifact.fieldsSig, artifact.functions);
639
+ return new Script(artifact.version, artifact.name, artifact.bytecodeTemplate, bytecodeDebugPatch, artifact.fieldsSig, artifact.functions);
636
640
  }
637
641
  static async fromArtifactFile(path, bytecodeDebugPatch) {
638
642
  const content = await fs_2.promises.readFile(path);
@@ -641,6 +645,7 @@ class Script extends Artifact {
641
645
  }
642
646
  toString() {
643
647
  const object = {
648
+ version: this.version,
644
649
  name: this.name,
645
650
  bytecodeTemplate: this.bytecodeTemplate,
646
651
  fieldsSig: this.fieldsSig,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alephium/web3",
3
- "version": "0.2.0-rc.37",
3
+ "version": "0.2.0-rc.38",
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,7 +27,7 @@
27
27
  },
28
28
  "author": "Alephium dev <dev@alephium.org>",
29
29
  "config": {
30
- "alephium_version": "1.5.0-rc12",
30
+ "alephium_version": "1.5.0-rc13",
31
31
  "explorer_backend_version": "1.9.0-rc2"
32
32
  },
33
33
  "scripts": {
@@ -80,7 +80,7 @@
80
80
  "ts-jest": "^28.0.2",
81
81
  "ts-node": "^10.7.0",
82
82
  "tslib": "^2.3.1",
83
- "typescript": "4.7.4",
83
+ "typescript": "^4.7.4",
84
84
  "webpack": "^5.72.0",
85
85
  "webpack-cli": "^4.9.2"
86
86
  },
@@ -435,6 +435,7 @@ export interface ChangeActiveAddress {
435
435
  }
436
436
 
437
437
  export interface CompileContractResult {
438
+ version: string
438
439
  name: string
439
440
  bytecode: string
440
441
  bytecodeDebugPatch: string
@@ -456,6 +457,7 @@ export interface CompileProjectResult {
456
457
  }
457
458
 
458
459
  export interface CompileScriptResult {
460
+ version: string
459
461
  name: string
460
462
  bytecodeTemplate: string
461
463
  bytecodeDebugPatch: string
@@ -2166,6 +2168,27 @@ export class Api<SecurityDataType extends unknown> extends HttpClient<SecurityDa
2166
2168
  ...params
2167
2169
  }).then(convertHttpResponse),
2168
2170
 
2171
+ /**
2172
+ * No description
2173
+ *
2174
+ * @tags Transactions
2175
+ * @name GetTransactionsDetailsTxid
2176
+ * @summary Get transaction details
2177
+ * @request GET:/transactions/details/{txId}
2178
+ */
2179
+ getTransactionsDetailsTxid: (
2180
+ txId: string,
2181
+ query?: { fromGroup?: number; toGroup?: number },
2182
+ params: RequestParams = {}
2183
+ ) =>
2184
+ this.request<Transaction, BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable>({
2185
+ path: `/transactions/details/${txId}`,
2186
+ method: 'GET',
2187
+ query: query,
2188
+ format: 'json',
2189
+ ...params
2190
+ }).then(convertHttpResponse),
2191
+
2169
2192
  /**
2170
2193
  * No description
2171
2194
  *
package/src/api/index.ts CHANGED
@@ -78,16 +78,16 @@ export class NodeProvider {
78
78
  nodeApi = param0 as NodeProvider
79
79
  }
80
80
 
81
- this.wallets = nodeApi.wallets
82
- this.infos = nodeApi.infos
83
- this.blockflow = nodeApi.blockflow
84
- this.addresses = nodeApi.addresses
85
- this.transactions = nodeApi.transactions
86
- this.contracts = nodeApi.contracts
87
- this.multisig = nodeApi.multisig
88
- this.utils = nodeApi.utils
89
- this.miners = nodeApi.miners
90
- this.events = nodeApi.events
81
+ this.wallets = { ...nodeApi.wallets }
82
+ this.infos = { ...nodeApi.infos }
83
+ this.blockflow = { ...nodeApi.blockflow }
84
+ this.addresses = { ...nodeApi.addresses }
85
+ this.transactions = { ...nodeApi.transactions }
86
+ this.contracts = { ...nodeApi.contracts }
87
+ this.multisig = { ...nodeApi.multisig }
88
+ this.utils = { ...nodeApi.utils }
89
+ this.miners = { ...nodeApi.miners }
90
+ this.events = { ...nodeApi.events }
91
91
  }
92
92
 
93
93
  request = (args: ApiRequestArguments): Promise<any> => {
@@ -140,16 +140,16 @@ export class ExplorerProvider {
140
140
  explorerApi = param0 as ExplorerProvider
141
141
  }
142
142
 
143
- this.blocks = explorerApi.blocks
144
- this.transactions = explorerApi.transactions
145
- this.transactionByOutputRefKey = explorerApi.transactionByOutputRefKey
146
- this.addresses = explorerApi.addresses
147
- this.addressesActive = explorerApi.addressesActive
148
- this.infos = explorerApi.infos
149
- this.unconfirmedTransactions = explorerApi.unconfirmedTransactions
150
- this.tokens = explorerApi.tokens
151
- this.charts = explorerApi.charts
152
- this.utils = explorerApi.utils
143
+ this.blocks = { ...explorerApi.blocks }
144
+ this.transactions = { ...explorerApi.transactions }
145
+ this.transactionByOutputRefKey = { ...explorerApi.transactionByOutputRefKey }
146
+ this.addresses = { ...explorerApi.addresses }
147
+ this.addressesActive = { ...explorerApi.addressesActive }
148
+ this.infos = { ...explorerApi.infos }
149
+ this.unconfirmedTransactions = { ...explorerApi.unconfirmedTransactions }
150
+ this.tokens = { ...explorerApi.tokens }
151
+ this.charts = { ...explorerApi.charts }
152
+ this.utils = { ...explorerApi.utils }
153
153
  }
154
154
 
155
155
  request = (args: ApiRequestArguments): Promise<any> => {
@@ -509,10 +509,12 @@ export class Project {
509
509
  }
510
510
 
511
511
  export abstract class Artifact {
512
+ readonly version: string
512
513
  readonly name: string
513
514
  readonly functions: FunctionSig[]
514
515
 
515
- constructor(name: string, functions: FunctionSig[]) {
516
+ constructor(version: string, name: string, functions: FunctionSig[]) {
517
+ this.version = version
516
518
  this.name = name
517
519
  this.functions = functions
518
520
  }
@@ -543,6 +545,7 @@ export class Contract extends Artifact {
543
545
  readonly codeHashDebug: string
544
546
 
545
547
  constructor(
548
+ version: string,
546
549
  name: string,
547
550
  bytecode: string,
548
551
  bytecodeDebugPatch: string,
@@ -552,7 +555,7 @@ export class Contract extends Artifact {
552
555
  eventsSig: EventSig[],
553
556
  functions: FunctionSig[]
554
557
  ) {
555
- super(name, functions)
558
+ super(version, name, functions)
556
559
  this.bytecode = bytecode
557
560
  this.bytecodeDebugPatch = bytecodeDebugPatch
558
561
  this.codeHash = codeHash
@@ -566,6 +569,7 @@ export class Contract extends Artifact {
566
569
  // TODO: safely parse json
567
570
  static fromJson(artifact: any, bytecodeDebugPatch = '', codeHashDebug = ''): Contract {
568
571
  if (
572
+ artifact.version == null ||
569
573
  artifact.name == null ||
570
574
  artifact.bytecode == null ||
571
575
  artifact.codeHash == null ||
@@ -576,6 +580,7 @@ export class Contract extends Artifact {
576
580
  throw Error('The artifact JSON for contract is incomplete')
577
581
  }
578
582
  const contract = new Contract(
583
+ artifact.version,
579
584
  artifact.name,
580
585
  artifact.bytecode,
581
586
  bytecodeDebugPatch,
@@ -590,6 +595,7 @@ export class Contract extends Artifact {
590
595
 
591
596
  static fromCompileResult(result: node.CompileContractResult): Contract {
592
597
  return new Contract(
598
+ result.version,
593
599
  result.name,
594
600
  result.bytecode,
595
601
  result.bytecodeDebugPatch,
@@ -617,6 +623,7 @@ export class Contract extends Artifact {
617
623
 
618
624
  override toString(): string {
619
625
  const object = {
626
+ version: this.version,
620
627
  name: this.name,
621
628
  bytecode: this.bytecode,
622
629
  codeHash: this.codeHash,
@@ -844,25 +851,34 @@ export class Script extends Artifact {
844
851
  readonly fieldsSig: FieldsSig
845
852
 
846
853
  constructor(
854
+ version: string,
847
855
  name: string,
848
856
  bytecodeTemplate: string,
849
857
  bytecodeDebugPatch: string,
850
858
  fieldsSig: FieldsSig,
851
859
  functions: FunctionSig[]
852
860
  ) {
853
- super(name, functions)
861
+ super(version, name, functions)
854
862
  this.bytecodeTemplate = bytecodeTemplate
855
863
  this.bytecodeDebugPatch = bytecodeDebugPatch
856
864
  this.fieldsSig = fieldsSig
857
865
  }
858
866
 
859
867
  static fromCompileResult(result: node.CompileScriptResult): Script {
860
- return new Script(result.name, result.bytecodeTemplate, result.bytecodeDebugPatch, result.fields, result.functions)
868
+ return new Script(
869
+ result.version,
870
+ result.name,
871
+ result.bytecodeTemplate,
872
+ result.bytecodeDebugPatch,
873
+ result.fields,
874
+ result.functions
875
+ )
861
876
  }
862
877
 
863
878
  // TODO: safely parse json
864
879
  static fromJson(artifact: any, bytecodeDebugPatch = ''): Script {
865
880
  if (
881
+ artifact.version == null ||
866
882
  artifact.name == null ||
867
883
  artifact.bytecodeTemplate == null ||
868
884
  artifact.fieldsSig == null ||
@@ -871,6 +887,7 @@ export class Script extends Artifact {
871
887
  throw Error('The artifact JSON for script is incomplete')
872
888
  }
873
889
  return new Script(
890
+ artifact.version,
874
891
  artifact.name,
875
892
  artifact.bytecodeTemplate,
876
893
  bytecodeDebugPatch,
@@ -887,6 +904,7 @@ export class Script extends Artifact {
887
904
 
888
905
  override toString(): string {
889
906
  const object = {
907
+ version: this.version,
890
908
  name: this.name,
891
909
  bytecodeTemplate: this.bytecodeTemplate,
892
910
  fieldsSig: this.fieldsSig,