@alephium/web3 0.2.0 → 0.2.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.
@@ -346,7 +346,7 @@ export interface CompilerOptions {
346
346
  ignoreUnusedVariablesWarnings?: boolean;
347
347
  ignoreUnusedFieldsWarnings?: boolean;
348
348
  ignoreUnusedPrivateFunctionsWarnings?: boolean;
349
- ignoreReadonlyCheckWarnings?: boolean;
349
+ ignoreUpdateFieldsCheckWarnings?: boolean;
350
350
  ignoreExternalCallCheckWarnings?: boolean;
351
351
  }
352
352
  export interface Confirmed {
@@ -908,7 +908,7 @@ export declare class HttpClient<SecurityDataType = unknown> {
908
908
  }
909
909
  /**
910
910
  * @title Alephium API
911
- * @version 1.5.0
911
+ * @version 1.5.3
912
912
  * @baseUrl ../
913
913
  */
914
914
  export declare class Api<SecurityDataType extends unknown> extends HttpClient<SecurityDataType> {
@@ -149,7 +149,7 @@ class HttpClient {
149
149
  exports.HttpClient = HttpClient;
150
150
  /**
151
151
  * @title Alephium API
152
- * @version 1.5.0
152
+ * @version 1.5.3
153
153
  * @baseUrl ../
154
154
  */
155
155
  class Api extends HttpClient {
@@ -118,6 +118,7 @@ export declare class Contract extends Artifact {
118
118
  toApiContractStates(states?: ContractState[]): node.ContractState[] | undefined;
119
119
  toTestContract(funcName: string, params: TestContractParams): node.TestContract;
120
120
  fromApiContractState(state: node.ContractState): ContractState;
121
+ static fromApiContractState(state: node.ContractState): ContractState;
121
122
  static ContractCreatedEvent: EventSig;
122
123
  static ContractDestroyedEvent: EventSig;
123
124
  static fromApiEvent(event: node.ContractEventByTxId, codeHash: string | undefined): ContractEventByTxId;
@@ -65,7 +65,7 @@ exports.DEFAULT_NODE_COMPILER_OPTIONS = {
65
65
  ignoreUnusedVariablesWarnings: false,
66
66
  ignoreUnusedFieldsWarnings: false,
67
67
  ignoreUnusedPrivateFunctionsWarnings: false,
68
- ignoreReadonlyCheckWarnings: false,
68
+ ignoreUpdateFieldsCheckWarnings: false,
69
69
  ignoreExternalCallCheckWarnings: false
70
70
  };
71
71
  exports.DEFAULT_COMPILER_OPTIONS = { errorOnWarnings: true, ...exports.DEFAULT_NODE_COMPILER_OPTIONS };
@@ -530,18 +530,21 @@ class Contract extends Artifact {
530
530
  };
531
531
  }
532
532
  fromApiContractState(state) {
533
- const contract = Project.currentProject.contractByCodeHash(state.codeHash);
534
533
  return {
535
534
  address: state.address,
536
535
  contractId: (0, utils_1.binToHex)((0, utils_1.contractIdFromAddress)(state.address)),
537
536
  bytecode: state.bytecode,
538
537
  initialStateHash: state.initialStateHash,
539
538
  codeHash: state.codeHash,
540
- fields: fromApiFields(state.fields, contract.fieldsSig),
541
- fieldsSig: contract.fieldsSig,
539
+ fields: fromApiFields(state.fields, this.fieldsSig),
540
+ fieldsSig: this.fieldsSig,
542
541
  asset: fromApiAsset(state.asset)
543
542
  };
544
543
  }
544
+ static fromApiContractState(state) {
545
+ const contract = Project.currentProject.contractByCodeHash(state.codeHash);
546
+ return contract.fromApiContractState(state);
547
+ }
545
548
  static fromApiEvent(event, codeHash) {
546
549
  let eventSig;
547
550
  if (event.eventIndex == -1) {
@@ -570,7 +573,7 @@ class Contract extends Artifact {
570
573
  contractAddress: result.address,
571
574
  returns: (0, api_1.fromApiArray)(result.returns, this.functions[`${methodIndex}`].returnTypes),
572
575
  gasUsed: result.gasUsed,
573
- contracts: result.contracts.map((contract) => this.fromApiContractState(contract)),
576
+ contracts: result.contracts.map((contract) => Contract.fromApiContractState(contract)),
574
577
  txOutputs: result.txOutputs.map(fromApiOutput),
575
578
  events: result.events.map((event) => {
576
579
  const contractAddress = event.contractAddress;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alephium/web3",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
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",
30
+ "alephium_version": "1.5.3",
31
31
  "explorer_backend_version": "1.9.0"
32
32
  },
33
33
  "scripts": {
@@ -471,7 +471,7 @@ export interface CompilerOptions {
471
471
  ignoreUnusedVariablesWarnings?: boolean
472
472
  ignoreUnusedFieldsWarnings?: boolean
473
473
  ignoreUnusedPrivateFunctionsWarnings?: boolean
474
- ignoreReadonlyCheckWarnings?: boolean
474
+ ignoreUpdateFieldsCheckWarnings?: boolean
475
475
  ignoreExternalCallCheckWarnings?: boolean
476
476
  }
477
477
 
@@ -1332,7 +1332,7 @@ export class HttpClient<SecurityDataType = unknown> {
1332
1332
 
1333
1333
  /**
1334
1334
  * @title Alephium API
1335
- * @version 1.5.0
1335
+ * @version 1.5.3
1336
1336
  * @baseUrl ../
1337
1337
  */
1338
1338
  export class Api<SecurityDataType extends unknown> extends HttpClient<SecurityDataType> {
@@ -69,7 +69,7 @@ export const DEFAULT_NODE_COMPILER_OPTIONS: node.CompilerOptions = {
69
69
  ignoreUnusedVariablesWarnings: false,
70
70
  ignoreUnusedFieldsWarnings: false,
71
71
  ignoreUnusedPrivateFunctionsWarnings: false,
72
- ignoreReadonlyCheckWarnings: false,
72
+ ignoreUpdateFieldsCheckWarnings: false,
73
73
  ignoreExternalCallCheckWarnings: false
74
74
  }
75
75
 
@@ -746,19 +746,23 @@ export class Contract extends Artifact {
746
746
  }
747
747
 
748
748
  fromApiContractState(state: node.ContractState): ContractState {
749
- const contract = Project.currentProject.contractByCodeHash(state.codeHash)
750
749
  return {
751
750
  address: state.address,
752
751
  contractId: binToHex(contractIdFromAddress(state.address)),
753
752
  bytecode: state.bytecode,
754
753
  initialStateHash: state.initialStateHash,
755
754
  codeHash: state.codeHash,
756
- fields: fromApiFields(state.fields, contract.fieldsSig),
757
- fieldsSig: contract.fieldsSig,
755
+ fields: fromApiFields(state.fields, this.fieldsSig),
756
+ fieldsSig: this.fieldsSig,
758
757
  asset: fromApiAsset(state.asset)
759
758
  }
760
759
  }
761
760
 
761
+ static fromApiContractState(state: node.ContractState): ContractState {
762
+ const contract = Project.currentProject.contractByCodeHash(state.codeHash)
763
+ return contract.fromApiContractState(state)
764
+ }
765
+
762
766
  static ContractCreatedEvent: EventSig = {
763
767
  name: 'ContractCreated',
764
768
  fieldNames: ['address'],
@@ -800,7 +804,7 @@ export class Contract extends Artifact {
800
804
  contractAddress: result.address,
801
805
  returns: fromApiArray(result.returns, this.functions[`${methodIndex}`].returnTypes),
802
806
  gasUsed: result.gasUsed,
803
- contracts: result.contracts.map((contract) => this.fromApiContractState(contract)),
807
+ contracts: result.contracts.map((contract) => Contract.fromApiContractState(contract)),
804
808
  txOutputs: result.txOutputs.map(fromApiOutput),
805
809
  events: result.events.map((event) => {
806
810
  const contractAddress = event.contractAddress