@alephium/web3 0.2.0-test.0 → 0.2.0-test.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.
Files changed (58) hide show
  1. package/contracts/add/add.ral +5 -8
  2. package/contracts/greeter/greeter.ral +3 -3
  3. package/contracts/greeter/greeter_interface.ral +1 -0
  4. package/contracts/greeter_main.ral +3 -5
  5. package/contracts/main.ral +0 -2
  6. package/contracts/sub/sub.ral +2 -1
  7. package/contracts/test/metadata.ral +18 -0
  8. package/contracts/test/warnings.ral +8 -0
  9. package/dist/alephium-web3.min.js +1 -1
  10. package/dist/alephium-web3.min.js.map +1 -1
  11. package/dist/scripts/create-project.js +2 -1
  12. package/dist/src/api/api-alephium.d.ts +37 -7
  13. package/dist/src/api/api-alephium.js +19 -3
  14. package/dist/src/api/api-explorer.d.ts +16 -0
  15. package/dist/src/api/api-explorer.js +26 -0
  16. package/dist/src/contract/contract.d.ts +86 -52
  17. package/dist/src/contract/contract.js +325 -218
  18. package/dist/src/global.d.ts +3 -0
  19. package/dist/src/global.js +38 -0
  20. package/dist/src/index.d.ts +1 -0
  21. package/dist/src/index.js +1 -0
  22. package/dist/src/signer/node-wallet.d.ts +1 -3
  23. package/dist/src/signer/node-wallet.js +2 -5
  24. package/dist/src/signer/signer.d.ts +1 -1
  25. package/dist/src/signer/signer.js +3 -2
  26. package/dist/src/test/index.d.ts +1 -2
  27. package/dist/src/test/index.js +4 -4
  28. package/dist/src/test/privatekey-wallet.d.ts +2 -3
  29. package/dist/src/test/privatekey-wallet.js +4 -4
  30. package/dist/src/utils/subscription.d.ts +0 -1
  31. package/dist/src/utils/subscription.js +2 -1
  32. package/dist/src/utils/utils.d.ts +2 -2
  33. package/dist/src/utils/utils.js +2 -2
  34. package/gitignore +0 -1
  35. package/package.json +3 -5
  36. package/scripts/create-project.ts +2 -1
  37. package/src/api/api-alephium.ts +57 -8
  38. package/src/api/api-explorer.ts +30 -0
  39. package/src/contract/contract.ts +430 -317
  40. package/src/contract/events.ts +2 -2
  41. package/src/contract/ralph.test.ts +4 -4
  42. package/src/global.ts +36 -0
  43. package/src/index.ts +1 -0
  44. package/src/signer/node-wallet.ts +2 -11
  45. package/src/signer/signer.ts +4 -3
  46. package/src/test/index.ts +2 -3
  47. package/src/test/privatekey-wallet.ts +4 -5
  48. package/src/transaction/status.ts +1 -1
  49. package/src/utils/subscription.ts +3 -3
  50. package/src/utils/utils.test.ts +1 -1
  51. package/src/utils/utils.ts +4 -4
  52. package/templates/base/package.json +2 -2
  53. package/templates/base/src/greeter.ts +8 -7
  54. package/templates/react/package.json +2 -2
  55. package/templates/react/src/App.tsx +2 -2
  56. package/test/contract.test.ts +60 -25
  57. package/test/events.test.ts +20 -17
  58. package/test/transaction.test.ts +10 -9
@@ -16,18 +16,19 @@ You should have received a copy of the GNU Lesser General Public License
16
16
  along with the library. If not, see <http://www.gnu.org/licenses/>.
17
17
  */
18
18
 
19
- import { NodeProvider } from '../src/api'
20
19
  import { subscribeToTxStatus } from '../src/transaction/status'
21
- import { Contract } from '../src/contract'
20
+ import { Project } from '../src/contract'
22
21
  import { TxStatus } from '../src/api/api-alephium'
23
- import { testWallet } from '../src/test'
22
+ import { testNodeWallet } from '../src/test'
24
23
  import { SubscribeOptions, timeout } from '../src/utils'
24
+ import { setCurrentNodeProvider } from '../src'
25
25
 
26
26
  describe('transactions', function () {
27
27
  it('should subscribe transaction status', async () => {
28
- const provider = new NodeProvider('http://127.0.0.1:22973')
29
- const sub = await Contract.fromSource(provider, 'sub.ral')
30
- const signer = await testWallet(provider)
28
+ setCurrentNodeProvider('http://127.0.0.1:22973')
29
+ await Project.build()
30
+ const sub = Project.contract('sub/sub.ral')
31
+ const signer = await testNodeWallet()
31
32
  const subDeployTx = await sub.transactionForDeployment(signer, {
32
33
  initialFields: { result: 0 },
33
34
  initialTokenAmounts: []
@@ -36,7 +37,6 @@ describe('transactions', function () {
36
37
  let txStatus: TxStatus | undefined = undefined
37
38
  let counter = 0
38
39
  const subscriptOptions: SubscribeOptions<TxStatus> = {
39
- provider: provider,
40
40
  pollingInterval: 500,
41
41
  messageCallback: (status: TxStatus): Promise<void> => {
42
42
  txStatus = status
@@ -56,7 +56,7 @@ describe('transactions', function () {
56
56
  await timeout(1500)
57
57
  expect(txStatus).toMatchObject({ type: 'TxNotFound' })
58
58
 
59
- const subSubmitResult = await signer.submitTransaction(subDeployTx.unsignedTx, subDeployTx.txId)
59
+ await signer.submitTransaction(subDeployTx.unsignedTx, subDeployTx.txId)
60
60
  await timeout(1500)
61
61
  expect(txStatus).toMatchObject({ type: 'Confirmed' })
62
62
 
@@ -67,6 +67,7 @@ describe('transactions', function () {
67
67
  const counterAfterUnsubscribe = counter
68
68
  await timeout(1500)
69
69
  expect(txStatus).toMatchObject({ type: 'Confirmed' })
70
- expect(counterAfterUnsubscribe).toEqual(counter)
70
+ // There maybe a pending request when we unsubscribe
71
+ expect([counter, counter - 1]).toContain(counterAfterUnsubscribe)
71
72
  }, 10000)
72
73
  })