@alephium/web3 0.2.0-rc.1 → 0.2.0-rc.10

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 (89) hide show
  1. package/.eslintignore +2 -2
  2. package/README.md +2 -135
  3. package/contracts/greeter/greeter.ral +2 -2
  4. package/contracts/greeter/greeter_interface.ral +1 -0
  5. package/contracts/greeter_main.ral +0 -2
  6. package/dist/alephium-web3.min.js +1 -1
  7. package/dist/alephium-web3.min.js.LICENSE.txt +0 -17
  8. package/dist/alephium-web3.min.js.map +1 -1
  9. package/dist/scripts/create-project.js +3 -2
  10. package/dist/src/api/api-alephium.d.ts +44 -11
  11. package/dist/src/api/api-alephium.js +16 -0
  12. package/dist/src/api/api-explorer.d.ts +16 -16
  13. package/dist/src/api/index.d.ts +2 -2
  14. package/dist/src/api/index.js +18 -3
  15. package/dist/src/contract/contract.d.ts +101 -52
  16. package/dist/src/contract/contract.js +353 -219
  17. package/dist/src/contract/index.js +5 -1
  18. package/dist/src/global.d.ts +4 -0
  19. package/dist/src/global.js +38 -0
  20. package/dist/src/index.d.ts +2 -0
  21. package/dist/src/index.js +20 -1
  22. package/dist/src/signer/index.d.ts +0 -1
  23. package/dist/src/signer/index.js +5 -2
  24. package/dist/src/signer/signer.d.ts +1 -1
  25. package/dist/src/signer/signer.js +8 -3
  26. package/dist/src/transaction/index.d.ts +0 -1
  27. package/dist/src/transaction/index.js +5 -2
  28. package/dist/src/utils/index.d.ts +0 -1
  29. package/dist/src/utils/index.js +5 -2
  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 +5 -4
  33. package/dist/src/utils/utils.js +17 -16
  34. package/jest-config.json +11 -0
  35. package/package.json +6 -34
  36. package/scripts/create-project.ts +3 -2
  37. package/src/api/api-alephium.ts +53 -5
  38. package/src/api/index.ts +13 -3
  39. package/src/contract/contract.ts +505 -318
  40. package/src/contract/events.ts +2 -2
  41. package/src/{transaction/sign-verify.ts → global.ts} +14 -15
  42. package/src/index.ts +3 -0
  43. package/src/signer/index.ts +0 -1
  44. package/src/signer/signer.ts +3 -2
  45. package/src/transaction/index.ts +0 -1
  46. package/src/transaction/status.ts +1 -1
  47. package/src/utils/index.ts +0 -1
  48. package/src/utils/subscription.ts +3 -3
  49. package/src/utils/utils.ts +10 -10
  50. package/templates/base/package.json +2 -2
  51. package/templates/base/src/greeter.ts +8 -7
  52. package/templates/react/package.json +2 -2
  53. package/templates/react/src/App.tsx +2 -2
  54. package/.eslintrc.json +0 -21
  55. package/LICENSE +0 -165
  56. package/contracts/add/add.ral +0 -16
  57. package/contracts/main.ral +0 -6
  58. package/contracts/sub/sub.ral +0 -9
  59. package/dist/src/signer/node-wallet.d.ts +0 -13
  60. package/dist/src/signer/node-wallet.js +0 -60
  61. package/dist/src/test/index.d.ts +0 -7
  62. package/dist/src/test/index.js +0 -41
  63. package/dist/src/test/privatekey-wallet.d.ts +0 -12
  64. package/dist/src/test/privatekey-wallet.js +0 -68
  65. package/dist/src/transaction/sign-verify.d.ts +0 -2
  66. package/dist/src/transaction/sign-verify.js +0 -58
  67. package/dist/src/utils/password-crypto.d.ts +0 -2
  68. package/dist/src/utils/password-crypto.js +0 -69
  69. package/gitignore +0 -10
  70. package/src/contract/ralph.test.ts +0 -178
  71. package/src/fixtures/address.json +0 -36
  72. package/src/fixtures/balance.json +0 -9
  73. package/src/fixtures/self-clique.json +0 -19
  74. package/src/fixtures/transaction.json +0 -13
  75. package/src/fixtures/transactions.json +0 -179
  76. package/src/signer/fixtures/genesis.json +0 -26
  77. package/src/signer/fixtures/wallets.json +0 -26
  78. package/src/signer/node-wallet.ts +0 -74
  79. package/src/test/index.ts +0 -32
  80. package/src/test/privatekey-wallet.ts +0 -58
  81. package/src/transaction/sign-verify.test.ts +0 -50
  82. package/src/utils/address.test.ts +0 -47
  83. package/src/utils/djb2.test.ts +0 -35
  84. package/src/utils/password-crypto.test.ts +0 -27
  85. package/src/utils/password-crypto.ts +0 -77
  86. package/src/utils/utils.test.ts +0 -161
  87. package/test/contract.test.ts +0 -178
  88. package/test/events.test.ts +0 -138
  89. package/test/transaction.test.ts +0 -72
@@ -31,7 +31,7 @@ export class EventSubscription extends Subscription<ContractEvent> {
31
31
  this.startPolling()
32
32
  }
33
33
 
34
- override startPolling() {
34
+ override startPolling(): void {
35
35
  this.eventEmitter.on('tick', async () => {
36
36
  await this.polling()
37
37
  })
@@ -42,7 +42,7 @@ export class EventSubscription extends Subscription<ContractEvent> {
42
42
  return this.fromCount
43
43
  }
44
44
 
45
- override async polling() {
45
+ override async polling(): Promise<void> {
46
46
  try {
47
47
  const events = await this.provider.events.getEventsContractContractaddress(this.contractAddress, {
48
48
  start: this.fromCount
@@ -16,24 +16,23 @@ 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 { ec as EC } from 'elliptic'
19
+ import { NodeProvider } from './api'
20
20
 
21
- import * as utils from '../utils'
21
+ let _currentNodeProvider: NodeProvider | undefined = undefined
22
22
 
23
- const ec = new EC('secp256k1')
24
-
25
- export function transactionSign(txHash: string, privateKey: string): string {
26
- const keyPair = ec.keyFromPrivate(privateKey)
27
- const signature = keyPair.sign(txHash)
28
-
29
- return utils.signatureEncode(signature)
23
+ export function setCurrentNodeProvider(provider: NodeProvider): void
24
+ export function setCurrentNodeProvider(baseUrl: string, apiKey?: string): void
25
+ export function setCurrentNodeProvider(provider: NodeProvider | string, apiKey?: string): void {
26
+ if (typeof provider == 'string') {
27
+ _currentNodeProvider = new NodeProvider(provider, apiKey)
28
+ } else {
29
+ _currentNodeProvider = provider
30
+ }
30
31
  }
31
32
 
32
- export function transactionVerifySignature(txHash: string, publicKey: string, signature: string): boolean {
33
- try {
34
- const key = ec.keyFromPublic(publicKey, 'hex')
35
- return key.verify(txHash, utils.signatureDecode(ec, signature))
36
- } catch (error) {
37
- return false
33
+ export function getCurrentNodeProvider(): NodeProvider {
34
+ if (typeof _currentNodeProvider === 'undefined') {
35
+ throw Error('No node provider is set.')
38
36
  }
37
+ return _currentNodeProvider
39
38
  }
package/src/index.ts CHANGED
@@ -23,3 +23,6 @@ export * from './utils'
23
23
  export * from './transaction'
24
24
 
25
25
  export * from './constants'
26
+ export * as web3 from './global'
27
+
28
+ export * as utils from './utils'
@@ -17,4 +17,3 @@ along with the library. If not, see <http://www.gnu.org/licenses/>.
17
17
  */
18
18
 
19
19
  export * from './signer'
20
- export * from './node-wallet'
@@ -23,6 +23,7 @@ import * as utils from '../utils'
23
23
  import { Eq, assertType } from '../utils'
24
24
  import blake from 'blakejs'
25
25
  import { Token } from '../api/api-alephium'
26
+ import { getCurrentNodeProvider } from '../global'
26
27
 
27
28
  const ec = new EC('secp256k1')
28
29
 
@@ -167,8 +168,8 @@ export abstract class SignerWithNodeProvider implements SignerProvider {
167
168
  }
168
169
  }
169
170
 
170
- constructor(provider: NodeProvider, alwaysSubmitTx: boolean) {
171
- this.provider = provider
171
+ constructor(alwaysSubmitTx: boolean) {
172
+ this.provider = getCurrentNodeProvider()
172
173
  this.alwaysSubmitTx = alwaysSubmitTx
173
174
  }
174
175
 
@@ -16,5 +16,4 @@ 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
- export * from './sign-verify'
20
19
  export * from './status'
@@ -33,7 +33,7 @@ export class TxStatusSubscription extends Subscription<TxStatus> {
33
33
  this.startPolling()
34
34
  }
35
35
 
36
- override async polling() {
36
+ override async polling(): Promise<void> {
37
37
  try {
38
38
  const txStatus = await this.provider.transactions.getTransactionsStatus({
39
39
  txId: this.txId,
@@ -19,6 +19,5 @@ along with the library. If not, see <http://www.gnu.org/licenses/>.
19
19
  export * from './address'
20
20
  export * from './bs58'
21
21
  export * from './djb2'
22
- export * from './password-crypto'
23
22
  export * from './utils'
24
23
  export * from './subscription'
@@ -17,13 +17,13 @@ along with the library. If not, see <http://www.gnu.org/licenses/>.
17
17
  */
18
18
 
19
19
  import EventEmitter from 'eventemitter3'
20
+ import { getCurrentNodeProvider } from '../global'
20
21
  import { NodeProvider } from '../api'
21
22
 
22
23
  type MessageCallback<Message> = (message: Message) => Promise<void>
23
24
  type ErrorCallback<Message> = (error: any, subscription: Subscription<Message>) => Promise<void>
24
25
 
25
26
  export interface SubscribeOptions<Message> {
26
- provider: NodeProvider
27
27
  pollingInterval: number
28
28
  messageCallback: MessageCallback<Message>
29
29
  errorCallback: ErrorCallback<Message>
@@ -40,7 +40,7 @@ export abstract class Subscription<Message> {
40
40
  protected cancelled: boolean
41
41
 
42
42
  constructor(options: SubscribeOptions<Message>) {
43
- this.provider = options.provider
43
+ this.provider = getCurrentNodeProvider()
44
44
  this.pollingInterval = options.pollingInterval
45
45
  this.messageCallback = options.messageCallback
46
46
  this.errorCallback = options.errorCallback
@@ -49,7 +49,7 @@ export abstract class Subscription<Message> {
49
49
  this.eventEmitter = new EventEmitter()
50
50
  }
51
51
 
52
- startPolling() {
52
+ startPolling(): void {
53
53
  this.eventEmitter.on('tick', async () => {
54
54
  await this.polling()
55
55
 
@@ -51,7 +51,7 @@ export function signatureEncode(signature: EC.Signature): string {
51
51
  }
52
52
 
53
53
  // the signature should be in hex string format for 64 bytes
54
- export const signatureDecode = (ec: EC, signature: string): SignatureInput => {
54
+ export function signatureDecode(ec: EC, signature: string): SignatureInput {
55
55
  if (signature.length !== 128) {
56
56
  throw new Error('Invalid signature length')
57
57
  }
@@ -66,7 +66,7 @@ export const signatureDecode = (ec: EC, signature: string): SignatureInput => {
66
66
  }
67
67
  }
68
68
 
69
- const xorByte = (intValue: number) => {
69
+ export function xorByte(intValue: number): number {
70
70
  const byte0 = (intValue >> 24) & 0xff
71
71
  const byte1 = (intValue >> 16) & 0xff
72
72
  const byte2 = (intValue >> 8) & 0xff
@@ -85,7 +85,7 @@ enum AddressType {
85
85
  P2C = 0x03
86
86
  }
87
87
 
88
- export const groupOfAddress = (address: string): number => {
88
+ export function groupOfAddress(address: string): number {
89
89
  const decoded = bs58.decode(address)
90
90
 
91
91
  if (decoded.length == 0) throw new Error('Address string is empty')
@@ -103,7 +103,7 @@ export const groupOfAddress = (address: string): number => {
103
103
  }
104
104
  }
105
105
 
106
- const groupOfAddressBytes = (bytes: Uint8Array): number => {
106
+ function groupOfAddressBytes(bytes: Uint8Array): number {
107
107
  const hint = djb2(bytes) | 1
108
108
  const hash = xorByte(hint)
109
109
  const group = hash % TOTAL_NUMBER_OF_GROUPS
@@ -111,7 +111,7 @@ const groupOfAddressBytes = (bytes: Uint8Array): number => {
111
111
  }
112
112
 
113
113
  // Pay to public key hash address
114
- const groupOfP2pkhAddress = (address: Uint8Array): number => {
114
+ function groupOfP2pkhAddress(address: Uint8Array): number {
115
115
  if (address.length != 32) {
116
116
  throw new Error(`Invalid p2pkh address length: ${address.length}`)
117
117
  }
@@ -120,7 +120,7 @@ const groupOfP2pkhAddress = (address: Uint8Array): number => {
120
120
  }
121
121
 
122
122
  // Pay to multiple public key hash address
123
- const groupOfP2mpkhAddress = (address: Uint8Array): number => {
123
+ function groupOfP2mpkhAddress(address: Uint8Array): number {
124
124
  if ((address.length - 2) % 32 != 0) {
125
125
  throw new Error(`Invalid p2mpkh address length: ${address.length}`)
126
126
  }
@@ -129,7 +129,7 @@ const groupOfP2mpkhAddress = (address: Uint8Array): number => {
129
129
  }
130
130
 
131
131
  // Pay to script hash address
132
- const groupOfP2shAddress = (address: Uint8Array): number => {
132
+ function groupOfP2shAddress(address: Uint8Array): number {
133
133
  return groupOfAddressBytes(address)
134
134
  }
135
135
 
@@ -203,11 +203,11 @@ export function stringToHex(str: string): string {
203
203
  return hex
204
204
  }
205
205
 
206
- export function hexToString(str: any): string {
207
- return Buffer.from(str.toString(), 'hex').toString()
206
+ export function hexToString(str: string): string {
207
+ return Buffer.from(str, 'hex').toString()
208
208
  }
209
209
 
210
- export function timeout(ms: number) {
210
+ export function timeout(ms: number): Promise<void> {
211
211
  return new Promise((resolve) => setTimeout(resolve, ms))
212
212
  }
213
213
 
@@ -3,7 +3,7 @@
3
3
  "version": "0.1.0",
4
4
  "license": "GPL",
5
5
  "config": {
6
- "alephium_version": "1.5.0-rc0"
6
+ "alephium_version": "1.5.0-rc7"
7
7
  },
8
8
  "scripts": {
9
9
  "build": "rm -rf dist && npx tsc --build .",
@@ -12,7 +12,7 @@
12
12
  "stop-devnet": "node scripts/stop-devnet.js"
13
13
  },
14
14
  "dependencies": {
15
- "@alephium/web3": "0.2.0-rc.1"
15
+ "@alephium/web3": "0.2.0-rc.9"
16
16
  },
17
17
  "devDependencies": {
18
18
  "@types/elliptic": "^6.4.13",
@@ -2,21 +2,22 @@
2
2
  * greeter.ts
3
3
  */
4
4
 
5
- import { NodeProvider, Contract, Script, TestContractParams } from '@alephium/web3'
6
- import { testWallet } from '@alephium/web3/test'
5
+ import { TestContractParams, web3, Project } from '@alephium/web3'
6
+ import { testNodeWallet } from '@alephium/web3/test'
7
7
 
8
8
  async function greet() {
9
- const provider = new NodeProvider('http://127.0.0.1:22973')
9
+ web3.setCurrentNodeProvider('http://127.0.0.1:22973')
10
+ await Project.build()
10
11
 
11
- const greeter = await Contract.fromSource(provider, 'greeter.ral')
12
+ const greeter = Project.contract('greeter/greeter.ral')
12
13
 
13
14
  const testParams: TestContractParams = {
14
15
  initialFields: { btcPrice: 1 }
15
16
  }
16
- const testResult = await greeter.testPublicMethod(provider, 'greet', testParams)
17
+ const testResult = await greeter.testPublicMethod('greet', testParams)
17
18
  console.log(testResult)
18
19
 
19
- const signer = await testWallet(provider)
20
+ const signer = await testNodeWallet()
20
21
 
21
22
  const deployTx = await greeter.transactionForDeployment(signer, { initialFields: testParams.initialFields })
22
23
  const greeterContractId = deployTx.contractId
@@ -26,7 +27,7 @@ async function greet() {
26
27
  const submitResult = await signer.submitTransaction(deployTx.unsignedTx, deployTx.txId)
27
28
  console.log(submitResult)
28
29
 
29
- const main = await Script.fromSource(provider, 'greeter_main.ral')
30
+ const main = Project.script('greeter_main.ral')
30
31
 
31
32
  const mainScriptTx = await main.transactionForDeployment(signer, {
32
33
  initialFields: { greeterContractId: greeterContractId }
@@ -2,7 +2,7 @@
2
2
  "name": "my-dapp",
3
3
  "version": "0.1.0",
4
4
  "config": {
5
- "alephium_version": "1.5.0-rc0"
5
+ "alephium_version": "1.5.0-rc7"
6
6
  },
7
7
  "dependencies": {
8
8
  "@testing-library/jest-dom": "^5.16.4",
@@ -12,7 +12,7 @@
12
12
  "@types/node": "^16.11.26",
13
13
  "@types/react": "^18.0.3",
14
14
  "@types/react-dom": "^18.0.0",
15
- "@alephium/web3": "0.2.0-rc.1",
15
+ "@alephium/web3": "0.2.0-rc.9",
16
16
  "react": "^18.0.0",
17
17
  "react-dom": "^18.0.0",
18
18
  "react-scripts": "5.0.1",
@@ -1,12 +1,12 @@
1
1
  import React, { useEffect, useState } from 'react'
2
2
  import './App.css'
3
3
 
4
- import { explorer, Contract, Script } from '@alephium/web3'
4
+ import { ExplorerProvider, Contract, Script } from '@alephium/web3'
5
5
  import contractJson from './artifacts/greeter.ral.json'
6
6
  import scriptJson from './artifacts/greeter_main.ral.json'
7
7
 
8
8
  function Dashboard() {
9
- const api = new explorer.Api<null>({ baseUrl: 'https://mainnet-backend.alephium.org' })
9
+ const api = new ExplorerProvider('https://mainnet-backend.alephium.org')
10
10
  const contract = Contract.fromJson(contractJson).toString()
11
11
  const script = Script.fromJson(scriptJson).toString()
12
12
  const [blocks, setBlocks] = useState('')
package/.eslintrc.json DELETED
@@ -1,21 +0,0 @@
1
- {
2
- "plugins": ["security", "header"],
3
- "extends": [
4
- "prettier",
5
- "plugin:prettier/recommended",
6
- "plugin:security/recommended",
7
- "plugin:@typescript-eslint/recommended"
8
- ],
9
- "parser": "@typescript-eslint/parser",
10
- "rules": {
11
- "header/header": [2, "scripts/header.js"]
12
- },
13
- "overrides": [
14
- {
15
- "files": ["*.ts"],
16
- "rules": {
17
- "security/detect-non-literal-fs-filename": "off"
18
- }
19
- }
20
- ]
21
- }
package/LICENSE DELETED
@@ -1,165 +0,0 @@
1
- GNU LESSER GENERAL PUBLIC LICENSE
2
- Version 3, 29 June 2007
3
-
4
- Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
5
- Everyone is permitted to copy and distribute verbatim copies
6
- of this license document, but changing it is not allowed.
7
-
8
-
9
- This version of the GNU Lesser General Public License incorporates
10
- the terms and conditions of version 3 of the GNU General Public
11
- License, supplemented by the additional permissions listed below.
12
-
13
- 0. Additional Definitions.
14
-
15
- As used herein, "this License" refers to version 3 of the GNU Lesser
16
- General Public License, and the "GNU GPL" refers to version 3 of the GNU
17
- General Public License.
18
-
19
- "The Library" refers to a covered work governed by this License,
20
- other than an Application or a Combined Work as defined below.
21
-
22
- An "Application" is any work that makes use of an interface provided
23
- by the Library, but which is not otherwise based on the Library.
24
- Defining a subclass of a class defined by the Library is deemed a mode
25
- of using an interface provided by the Library.
26
-
27
- A "Combined Work" is a work produced by combining or linking an
28
- Application with the Library. The particular version of the Library
29
- with which the Combined Work was made is also called the "Linked
30
- Version".
31
-
32
- The "Minimal Corresponding Source" for a Combined Work means the
33
- Corresponding Source for the Combined Work, excluding any source code
34
- for portions of the Combined Work that, considered in isolation, are
35
- based on the Application, and not on the Linked Version.
36
-
37
- The "Corresponding Application Code" for a Combined Work means the
38
- object code and/or source code for the Application, including any data
39
- and utility programs needed for reproducing the Combined Work from the
40
- Application, but excluding the System Libraries of the Combined Work.
41
-
42
- 1. Exception to Section 3 of the GNU GPL.
43
-
44
- You may convey a covered work under sections 3 and 4 of this License
45
- without being bound by section 3 of the GNU GPL.
46
-
47
- 2. Conveying Modified Versions.
48
-
49
- If you modify a copy of the Library, and, in your modifications, a
50
- facility refers to a function or data to be supplied by an Application
51
- that uses the facility (other than as an argument passed when the
52
- facility is invoked), then you may convey a copy of the modified
53
- version:
54
-
55
- a) under this License, provided that you make a good faith effort to
56
- ensure that, in the event an Application does not supply the
57
- function or data, the facility still operates, and performs
58
- whatever part of its purpose remains meaningful, or
59
-
60
- b) under the GNU GPL, with none of the additional permissions of
61
- this License applicable to that copy.
62
-
63
- 3. Object Code Incorporating Material from Library Header Files.
64
-
65
- The object code form of an Application may incorporate material from
66
- a header file that is part of the Library. You may convey such object
67
- code under terms of your choice, provided that, if the incorporated
68
- material is not limited to numerical parameters, data structure
69
- layouts and accessors, or small macros, inline functions and templates
70
- (ten or fewer lines in length), you do both of the following:
71
-
72
- a) Give prominent notice with each copy of the object code that the
73
- Library is used in it and that the Library and its use are
74
- covered by this License.
75
-
76
- b) Accompany the object code with a copy of the GNU GPL and this license
77
- document.
78
-
79
- 4. Combined Works.
80
-
81
- You may convey a Combined Work under terms of your choice that,
82
- taken together, effectively do not restrict modification of the
83
- portions of the Library contained in the Combined Work and reverse
84
- engineering for debugging such modifications, if you also do each of
85
- the following:
86
-
87
- a) Give prominent notice with each copy of the Combined Work that
88
- the Library is used in it and that the Library and its use are
89
- covered by this License.
90
-
91
- b) Accompany the Combined Work with a copy of the GNU GPL and this license
92
- document.
93
-
94
- c) For a Combined Work that displays copyright notices during
95
- execution, include the copyright notice for the Library among
96
- these notices, as well as a reference directing the user to the
97
- copies of the GNU GPL and this license document.
98
-
99
- d) Do one of the following:
100
-
101
- 0) Convey the Minimal Corresponding Source under the terms of this
102
- License, and the Corresponding Application Code in a form
103
- suitable for, and under terms that permit, the user to
104
- recombine or relink the Application with a modified version of
105
- the Linked Version to produce a modified Combined Work, in the
106
- manner specified by section 6 of the GNU GPL for conveying
107
- Corresponding Source.
108
-
109
- 1) Use a suitable shared library mechanism for linking with the
110
- Library. A suitable mechanism is one that (a) uses at run time
111
- a copy of the Library already present on the user's computer
112
- system, and (b) will operate properly with a modified version
113
- of the Library that is interface-compatible with the Linked
114
- Version.
115
-
116
- e) Provide Installation Information, but only if you would otherwise
117
- be required to provide such information under section 6 of the
118
- GNU GPL, and only to the extent that such information is
119
- necessary to install and execute a modified version of the
120
- Combined Work produced by recombining or relinking the
121
- Application with a modified version of the Linked Version. (If
122
- you use option 4d0, the Installation Information must accompany
123
- the Minimal Corresponding Source and Corresponding Application
124
- Code. If you use option 4d1, you must provide the Installation
125
- Information in the manner specified by section 6 of the GNU GPL
126
- for conveying Corresponding Source.)
127
-
128
- 5. Combined Libraries.
129
-
130
- You may place library facilities that are a work based on the
131
- Library side by side in a single library together with other library
132
- facilities that are not Applications and are not covered by this
133
- License, and convey such a combined library under terms of your
134
- choice, if you do both of the following:
135
-
136
- a) Accompany the combined library with a copy of the same work based
137
- on the Library, uncombined with any other library facilities,
138
- conveyed under the terms of this License.
139
-
140
- b) Give prominent notice with the combined library that part of it
141
- is a work based on the Library, and explaining where to find the
142
- accompanying uncombined form of the same work.
143
-
144
- 6. Revised Versions of the GNU Lesser General Public License.
145
-
146
- The Free Software Foundation may publish revised and/or new versions
147
- of the GNU Lesser General Public License from time to time. Such new
148
- versions will be similar in spirit to the present version, but may
149
- differ in detail to address new problems or concerns.
150
-
151
- Each version is given a distinguishing version number. If the
152
- Library as you received it specifies that a certain numbered version
153
- of the GNU Lesser General Public License "or any later version"
154
- applies to it, you have the option of following the terms and
155
- conditions either of that published version or of any later version
156
- published by the Free Software Foundation. If the Library as you
157
- received it does not specify a version number of the GNU Lesser
158
- General Public License, you may choose any version of the GNU Lesser
159
- General Public License ever published by the Free Software Foundation.
160
-
161
- If the Library as you received it specifies that a proxy can decide
162
- whether future versions of the GNU Lesser General Public License shall
163
- apply, that proxy's public statement of acceptance of any version is
164
- permanent authorization for you to choose that version for the
165
- Library.
@@ -1,16 +0,0 @@
1
- import "../sub/sub.ral"
2
-
3
- Contract Add(subContractId: ByteVec, mut result : U256) {
4
- event Add(x: U256, y: U256)
5
-
6
- pub fn add(array: [U256; 2]) -> ([U256; 2]) {
7
- emit Add(array[0], array[1])
8
- let sub = Sub(subContractId)
9
- result = result + array[0] + array[1]
10
- return [result, sub.sub(array)]
11
- }
12
-
13
- fn addPrivate(array: [U256; 2]) -> ([U256; 2]) {
14
- return add(array)
15
- }
16
- }
@@ -1,6 +0,0 @@
1
- import "./add/add.ral"
2
-
3
- TxScript Main(addContractId: ByteVec) {
4
- let add = Add(addContractId)
5
- add.add([2, 1])
6
- }
@@ -1,9 +0,0 @@
1
- Contract Sub(mut result : U256) {
2
- event Sub(x: U256, y: U256)
3
-
4
- pub fn sub(array: [U256; 2]) -> U256 {
5
- emit Sub(array[0], array[1])
6
- result = result + array[0] - array[1]
7
- return result
8
- }
9
- }
@@ -1,13 +0,0 @@
1
- import { NodeProvider } from '../api';
2
- import { Account, SignerWithNodeProvider } from '../signer';
3
- export declare class NodeWallet extends SignerWithNodeProvider {
4
- walletName: string;
5
- accounts: Account[] | undefined;
6
- constructor(provider: NodeProvider, walletName: string, alwaysSubmitTx?: boolean);
7
- getAccounts(): Promise<Account[]>;
8
- private getAllAccounts;
9
- static FromCliqueClient(provider: NodeProvider, walletName: string, alwaysSubmitTx?: boolean): Promise<NodeWallet>;
10
- signRaw(signerAddress: string, hexString: string): Promise<string>;
11
- unlock(password: string): Promise<void>;
12
- lock(): Promise<void>;
13
- }
@@ -1,60 +0,0 @@
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 });
20
- exports.NodeWallet = void 0;
21
- const signer_1 = require("../signer");
22
- class NodeWallet extends signer_1.SignerWithNodeProvider {
23
- constructor(provider, walletName, alwaysSubmitTx = true) {
24
- super(provider, alwaysSubmitTx);
25
- this.walletName = walletName;
26
- }
27
- async getAccounts() {
28
- if (typeof this.accounts === 'undefined') {
29
- this.accounts = await this.getAllAccounts();
30
- }
31
- return this.accounts;
32
- }
33
- async getAllAccounts() {
34
- const walletAddresses = await this.provider.wallets.getWalletsWalletNameAddresses(this.walletName);
35
- const accounts = walletAddresses.addresses.map((acc) => ({
36
- publicKey: acc.publicKey,
37
- address: acc.address,
38
- group: acc.group
39
- }));
40
- return accounts;
41
- }
42
- static async FromCliqueClient(provider, walletName, alwaysSubmitTx = true) {
43
- return new NodeWallet(provider, walletName, alwaysSubmitTx);
44
- }
45
- async signRaw(signerAddress, hexString) {
46
- const currentActiveAddressResponse = await this.provider.wallets.getWalletsWalletNameAddresses(this.walletName);
47
- const { activeAddress } = currentActiveAddressResponse;
48
- await this.provider.wallets.postWalletsWalletNameChangeActiveAddress(this.walletName, { address: signerAddress });
49
- const { signature } = await this.provider.wallets.postWalletsWalletNameSign(this.walletName, { data: hexString });
50
- await this.provider.wallets.postWalletsWalletNameChangeActiveAddress(this.walletName, { address: activeAddress }); // set the address that's active back to previous state
51
- return signature;
52
- }
53
- async unlock(password) {
54
- return await this.provider.wallets.postWalletsWalletNameUnlock(this.walletName, { password });
55
- }
56
- async lock() {
57
- return await this.provider.wallets.postWalletsWalletNameLock(this.walletName);
58
- }
59
- }
60
- exports.NodeWallet = NodeWallet;
@@ -1,7 +0,0 @@
1
- import { NodeProvider } from '../api';
2
- import { NodeWallet } from '../signer';
3
- export declare const testWalletName = "alephium-web3-test-only-wallet";
4
- export declare const testAddress = "1DrDyTr9RpRsQnDnXo2YRiPzPW4ooHX5LLoqXrqfMrpQH";
5
- export declare const testPassword = "alph";
6
- export declare function testWallet(provider: NodeProvider): Promise<NodeWallet>;
7
- export * from './privatekey-wallet';