@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.
- package/contracts/add/add.ral +5 -8
- package/contracts/greeter/greeter.ral +3 -3
- package/contracts/greeter/greeter_interface.ral +1 -0
- package/contracts/greeter_main.ral +3 -5
- package/contracts/main.ral +0 -2
- package/contracts/sub/sub.ral +2 -1
- package/contracts/test/metadata.ral +18 -0
- package/contracts/test/warnings.ral +8 -0
- package/dist/alephium-web3.min.js +1 -1
- package/dist/alephium-web3.min.js.map +1 -1
- package/dist/scripts/create-project.js +2 -1
- package/dist/src/api/api-alephium.d.ts +37 -7
- package/dist/src/api/api-alephium.js +19 -3
- package/dist/src/api/api-explorer.d.ts +16 -0
- package/dist/src/api/api-explorer.js +26 -0
- package/dist/src/contract/contract.d.ts +86 -52
- package/dist/src/contract/contract.js +325 -218
- package/dist/src/global.d.ts +3 -0
- package/dist/src/global.js +38 -0
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.js +1 -0
- package/dist/src/signer/node-wallet.d.ts +1 -3
- package/dist/src/signer/node-wallet.js +2 -5
- package/dist/src/signer/signer.d.ts +1 -1
- package/dist/src/signer/signer.js +3 -2
- package/dist/src/test/index.d.ts +1 -2
- package/dist/src/test/index.js +4 -4
- package/dist/src/test/privatekey-wallet.d.ts +2 -3
- package/dist/src/test/privatekey-wallet.js +4 -4
- package/dist/src/utils/subscription.d.ts +0 -1
- package/dist/src/utils/subscription.js +2 -1
- package/dist/src/utils/utils.d.ts +2 -2
- package/dist/src/utils/utils.js +2 -2
- package/gitignore +0 -1
- package/package.json +3 -5
- package/scripts/create-project.ts +2 -1
- package/src/api/api-alephium.ts +57 -8
- package/src/api/api-explorer.ts +30 -0
- package/src/contract/contract.ts +430 -317
- package/src/contract/events.ts +2 -2
- package/src/contract/ralph.test.ts +4 -4
- package/src/global.ts +36 -0
- package/src/index.ts +1 -0
- package/src/signer/node-wallet.ts +2 -11
- package/src/signer/signer.ts +4 -3
- package/src/test/index.ts +2 -3
- package/src/test/privatekey-wallet.ts +4 -5
- package/src/transaction/status.ts +1 -1
- package/src/utils/subscription.ts +3 -3
- package/src/utils/utils.test.ts +1 -1
- package/src/utils/utils.ts +4 -4
- package/templates/base/package.json +2 -2
- package/templates/base/src/greeter.ts +8 -7
- package/templates/react/package.json +2 -2
- package/templates/react/src/App.tsx +2 -2
- package/test/contract.test.ts +60 -25
- package/test/events.test.ts +20 -17
- package/test/transaction.test.ts +10 -9
package/test/transaction.test.ts
CHANGED
|
@@ -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 {
|
|
20
|
+
import { Project } from '../src/contract'
|
|
22
21
|
import { TxStatus } from '../src/api/api-alephium'
|
|
23
|
-
import {
|
|
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
|
-
|
|
29
|
-
|
|
30
|
-
const
|
|
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
|
-
|
|
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
|
-
|
|
70
|
+
// There maybe a pending request when we unsubscribe
|
|
71
|
+
expect([counter, counter - 1]).toContain(counterAfterUnsubscribe)
|
|
71
72
|
}, 10000)
|
|
72
73
|
})
|