@alephium/web3 0.2.0-test.1 → 0.2.0

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 (128) hide show
  1. package/.eslintignore +2 -2
  2. package/README.md +2 -135
  3. package/dist/alephium-web3.min.js +1 -1
  4. package/dist/alephium-web3.min.js.LICENSE.txt +0 -17
  5. package/dist/alephium-web3.min.js.map +1 -1
  6. package/dist/src/api/api-alephium.d.ts +115 -17
  7. package/dist/src/api/api-alephium.js +145 -80
  8. package/dist/src/api/api-explorer.d.ts +178 -51
  9. package/dist/src/api/api-explorer.js +172 -37
  10. package/dist/src/api/index.d.ts +40 -5
  11. package/dist/src/api/index.js +115 -7
  12. package/dist/src/api/types.d.ts +23 -0
  13. package/dist/src/api/types.js +235 -0
  14. package/dist/src/api/utils.d.ts +6 -0
  15. package/dist/{scripts/rename-gitignore.js → src/api/utils.js} +11 -6
  16. package/dist/src/contract/contract.d.ts +68 -55
  17. package/dist/src/contract/contract.js +235 -384
  18. package/dist/src/contract/events.d.ts +4 -4
  19. package/dist/src/contract/events.js +2 -1
  20. package/dist/src/contract/index.js +5 -1
  21. package/dist/src/contract/ralph.d.ts +5 -4
  22. package/dist/src/contract/ralph.js +27 -1
  23. package/dist/src/global.d.ts +6 -2
  24. package/dist/src/global.js +19 -3
  25. package/dist/src/index.d.ts +2 -1
  26. package/dist/src/index.js +23 -2
  27. package/dist/src/signer/index.d.ts +0 -1
  28. package/dist/src/signer/index.js +5 -2
  29. package/dist/src/signer/signer.d.ts +59 -60
  30. package/dist/src/signer/signer.js +99 -70
  31. package/dist/src/transaction/index.d.ts +0 -1
  32. package/dist/src/transaction/index.js +5 -2
  33. package/dist/src/transaction/status.d.ts +2 -1
  34. package/dist/src/transaction/status.js +2 -1
  35. package/dist/src/utils/bs58.d.ts +1 -0
  36. package/dist/src/utils/bs58.js +13 -1
  37. package/dist/src/utils/index.d.ts +0 -1
  38. package/dist/src/utils/index.js +5 -2
  39. package/dist/src/utils/subscription.d.ts +0 -2
  40. package/dist/src/utils/subscription.js +0 -2
  41. package/dist/src/utils/utils.d.ts +4 -9
  42. package/dist/src/utils/utils.js +20 -24
  43. package/jest-config.json +11 -0
  44. package/package.json +11 -45
  45. package/src/api/api-alephium.ts +162 -25
  46. package/src/api/api-explorer.ts +247 -54
  47. package/src/api/index.ts +140 -6
  48. package/src/api/types.ts +229 -0
  49. package/{scripts/rename-gitignore.js → src/api/utils.ts} +7 -6
  50. package/src/contract/contract.ts +398 -429
  51. package/src/contract/events.ts +6 -5
  52. package/src/contract/ralph.ts +29 -4
  53. package/src/global.ts +23 -3
  54. package/src/index.ts +7 -1
  55. package/src/signer/index.ts +0 -1
  56. package/src/signer/signer.ts +165 -135
  57. package/src/transaction/index.ts +0 -1
  58. package/src/transaction/status.ts +5 -2
  59. package/src/utils/bs58.ts +11 -0
  60. package/src/utils/index.ts +0 -1
  61. package/src/utils/subscription.ts +0 -4
  62. package/src/utils/utils.ts +11 -19
  63. package/webpack.config.js +3 -0
  64. package/.eslintrc.json +0 -21
  65. package/LICENSE +0 -165
  66. package/contracts/add/add.ral +0 -13
  67. package/contracts/greeter/greeter.ral +0 -7
  68. package/contracts/greeter/greeter_interface.ral +0 -4
  69. package/contracts/greeter_main.ral +0 -7
  70. package/contracts/main.ral +0 -4
  71. package/contracts/sub/sub.ral +0 -10
  72. package/contracts/test/metadata.ral +0 -18
  73. package/contracts/test/warnings.ral +0 -8
  74. package/dev/user.conf +0 -29
  75. package/dist/scripts/create-project.d.ts +0 -2
  76. package/dist/scripts/create-project.js +0 -125
  77. package/dist/scripts/rename-gitignore.d.ts +0 -1
  78. package/dist/scripts/start-devnet.d.ts +0 -1
  79. package/dist/scripts/start-devnet.js +0 -131
  80. package/dist/scripts/stop-devnet.d.ts +0 -1
  81. package/dist/scripts/stop-devnet.js +0 -32
  82. package/dist/src/signer/node-wallet.d.ts +0 -11
  83. package/dist/src/signer/node-wallet.js +0 -57
  84. package/dist/src/test/index.d.ts +0 -6
  85. package/dist/src/test/index.js +0 -41
  86. package/dist/src/test/privatekey-wallet.d.ts +0 -11
  87. package/dist/src/test/privatekey-wallet.js +0 -68
  88. package/dist/src/transaction/sign-verify.d.ts +0 -2
  89. package/dist/src/transaction/sign-verify.js +0 -58
  90. package/dist/src/utils/password-crypto.d.ts +0 -2
  91. package/dist/src/utils/password-crypto.js +0 -69
  92. package/gitignore +0 -9
  93. package/scripts/create-project.ts +0 -137
  94. package/scripts/start-devnet.js +0 -141
  95. package/scripts/stop-devnet.js +0 -32
  96. package/src/contract/ralph.test.ts +0 -178
  97. package/src/fixtures/address.json +0 -36
  98. package/src/fixtures/balance.json +0 -9
  99. package/src/fixtures/self-clique.json +0 -19
  100. package/src/fixtures/transaction.json +0 -13
  101. package/src/fixtures/transactions.json +0 -179
  102. package/src/signer/fixtures/genesis.json +0 -26
  103. package/src/signer/fixtures/wallets.json +0 -26
  104. package/src/signer/node-wallet.ts +0 -65
  105. package/src/test/index.ts +0 -31
  106. package/src/test/privatekey-wallet.ts +0 -57
  107. package/src/transaction/sign-verify.test.ts +0 -50
  108. package/src/transaction/sign-verify.ts +0 -39
  109. package/src/utils/address.test.ts +0 -47
  110. package/src/utils/djb2.test.ts +0 -35
  111. package/src/utils/password-crypto.test.ts +0 -27
  112. package/src/utils/password-crypto.ts +0 -77
  113. package/src/utils/utils.test.ts +0 -161
  114. package/templates/base/README.md +0 -34
  115. package/templates/base/package.json +0 -35
  116. package/templates/base/src/greeter.ts +0 -42
  117. package/templates/base/tsconfig.json +0 -19
  118. package/templates/react/README.md +0 -34
  119. package/templates/react/config-overrides.js +0 -18
  120. package/templates/react/package.json +0 -66
  121. package/templates/react/src/App.tsx +0 -42
  122. package/templates/react/src/artifacts/greeter.ral.json +0 -26
  123. package/templates/react/src/artifacts/greeter_main.ral.json +0 -22
  124. package/templates/shared/.eslintrc.json +0 -12
  125. package/templates/shared/scripts/header.js +0 -0
  126. package/test/contract.test.ts +0 -213
  127. package/test/events.test.ts +0 -141
  128. package/test/transaction.test.ts +0 -73
@@ -17,8 +17,6 @@ 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'
21
- import { NodeProvider } from '../api'
22
20
 
23
21
  type MessageCallback<Message> = (message: Message) => Promise<void>
24
22
  type ErrorCallback<Message> = (error: any, subscription: Subscription<Message>) => Promise<void>
@@ -30,7 +28,6 @@ export interface SubscribeOptions<Message> {
30
28
  }
31
29
 
32
30
  export abstract class Subscription<Message> {
33
- provider: NodeProvider
34
31
  pollingInterval: number
35
32
 
36
33
  protected messageCallback: MessageCallback<Message>
@@ -40,7 +37,6 @@ export abstract class Subscription<Message> {
40
37
  protected cancelled: boolean
41
38
 
42
39
  constructor(options: SubscribeOptions<Message>) {
43
- this.provider = getCurrentNodeProvider()
44
40
  this.pollingInterval = options.pollingInterval
45
41
  this.messageCallback = options.messageCallback
46
42
  this.errorCallback = options.errorCallback
@@ -24,21 +24,9 @@ import { Buffer } from 'buffer/'
24
24
 
25
25
  import { TOTAL_NUMBER_OF_GROUPS } from '../constants'
26
26
  import djb2 from './djb2'
27
- import * as node from '../api/api-alephium'
28
- import * as explorer from '../api/api-explorer'
29
27
 
30
28
  const ec = new EC('secp256k1')
31
29
 
32
- export function convertHttpResponse<T>(
33
- response: node.HttpResponse<T, { detail: string }> | explorer.HttpResponse<T, { detail: string }>
34
- ): T {
35
- if (response.error) {
36
- throw new Error(response.error.detail)
37
- } else {
38
- return response.data
39
- }
40
- }
41
-
42
30
  export function signatureEncode(signature: EC.Signature): string {
43
31
  let sNormalized = signature.s
44
32
  if (ec.n && signature.s.cmp(ec.nh) === 1) {
@@ -51,7 +39,7 @@ export function signatureEncode(signature: EC.Signature): string {
51
39
  }
52
40
 
53
41
  // the signature should be in hex string format for 64 bytes
54
- export const signatureDecode = (ec: EC, signature: string): SignatureInput => {
42
+ export function signatureDecode(ec: EC, signature: string): SignatureInput {
55
43
  if (signature.length !== 128) {
56
44
  throw new Error('Invalid signature length')
57
45
  }
@@ -66,7 +54,7 @@ export const signatureDecode = (ec: EC, signature: string): SignatureInput => {
66
54
  }
67
55
  }
68
56
 
69
- const xorByte = (intValue: number) => {
57
+ export function xorByte(intValue: number): number {
70
58
  const byte0 = (intValue >> 24) & 0xff
71
59
  const byte1 = (intValue >> 16) & 0xff
72
60
  const byte2 = (intValue >> 8) & 0xff
@@ -85,7 +73,7 @@ enum AddressType {
85
73
  P2C = 0x03
86
74
  }
87
75
 
88
- export const groupOfAddress = (address: string): number => {
76
+ export function groupOfAddress(address: string): number {
89
77
  const decoded = bs58.decode(address)
90
78
 
91
79
  if (decoded.length == 0) throw new Error('Address string is empty')
@@ -103,7 +91,7 @@ export const groupOfAddress = (address: string): number => {
103
91
  }
104
92
  }
105
93
 
106
- const groupOfAddressBytes = (bytes: Uint8Array): number => {
94
+ function groupOfAddressBytes(bytes: Uint8Array): number {
107
95
  const hint = djb2(bytes) | 1
108
96
  const hash = xorByte(hint)
109
97
  const group = hash % TOTAL_NUMBER_OF_GROUPS
@@ -111,7 +99,7 @@ const groupOfAddressBytes = (bytes: Uint8Array): number => {
111
99
  }
112
100
 
113
101
  // Pay to public key hash address
114
- const groupOfP2pkhAddress = (address: Uint8Array): number => {
102
+ function groupOfP2pkhAddress(address: Uint8Array): number {
115
103
  if (address.length != 32) {
116
104
  throw new Error(`Invalid p2pkh address length: ${address.length}`)
117
105
  }
@@ -120,7 +108,7 @@ const groupOfP2pkhAddress = (address: Uint8Array): number => {
120
108
  }
121
109
 
122
110
  // Pay to multiple public key hash address
123
- const groupOfP2mpkhAddress = (address: Uint8Array): number => {
111
+ function groupOfP2mpkhAddress(address: Uint8Array): number {
124
112
  if ((address.length - 2) % 32 != 0) {
125
113
  throw new Error(`Invalid p2mpkh address length: ${address.length}`)
126
114
  }
@@ -129,7 +117,7 @@ const groupOfP2mpkhAddress = (address: Uint8Array): number => {
129
117
  }
130
118
 
131
119
  // Pay to script hash address
132
- const groupOfP2shAddress = (address: Uint8Array): number => {
120
+ function groupOfP2shAddress(address: Uint8Array): number {
133
121
  return groupOfAddressBytes(address)
134
122
  }
135
123
 
@@ -163,6 +151,10 @@ export function binToHex(bin: Uint8Array): string {
163
151
  return Buffer.from(bin).toString('hex')
164
152
  }
165
153
 
154
+ export function groupOfPrivateKey(privateKey: string): number {
155
+ return groupOfAddress(addressFromPublicKey(publicKeyFromPrivateKey(privateKey)))
156
+ }
157
+
166
158
  export function publicKeyFromPrivateKey(privateKey: string): string {
167
159
  const key = ec.keyFromPrivate(privateKey)
168
160
  return key.getPublic(true, 'hex')
package/webpack.config.js CHANGED
@@ -51,6 +51,9 @@ module.exports = {
51
51
  type: 'umd'
52
52
  }
53
53
  },
54
+ experiments: {
55
+ asyncWebAssembly: true
56
+ },
54
57
  optimization: {
55
58
  minimize: true
56
59
  }
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,13 +0,0 @@
1
- Contract Add(sub: Sub, mut result : U256) {
2
- event Add(x: U256, y: U256)
3
-
4
- pub fn add(array: [U256; 2]) -> ([U256; 2]) {
5
- return addPrivate(array)
6
- }
7
-
8
- fn addPrivate(array: [U256; 2]) -> ([U256; 2]) {
9
- emit Add(array[0], array[1])
10
- result = result + array[0] + array[1]
11
- return [result, sub.sub(array)]
12
- }
13
- }
@@ -1,7 +0,0 @@
1
- Contract Greeter(btcPrice: U256) implements GreeterInterface {
2
- @using(readonly = true)
3
- pub fn greet() -> U256 {
4
- checkCaller!(true, 0)
5
- return btcPrice
6
- }
7
- }
@@ -1,4 +0,0 @@
1
- Interface GreeterInterface {
2
- @using(readonly = true)
3
- pub fn greet() -> U256
4
- }
@@ -1,7 +0,0 @@
1
- TxScript GreeterMain(greeterContractId: ByteVec) {
2
- let greeter0 = Greeter(greeterContractId)
3
- assert!(greeter0.greet() == 1, 0)
4
-
5
- let greeter1 = GreeterInterface(greeterContractId)
6
- assert!(greeter1.greet() == 1, 0)
7
- }
@@ -1,4 +0,0 @@
1
- TxScript Main(addContractId: ByteVec) {
2
- let add = Add(addContractId)
3
- add.add([2, 1])
4
- }
@@ -1,10 +0,0 @@
1
- Contract Sub(mut result : U256) {
2
- event Sub(x: U256, y: U256)
3
-
4
- @using(externalCallCheck = false)
5
- pub fn sub(array: [U256; 2]) -> U256 {
6
- emit Sub(array[0], array[1])
7
- result = result + array[0] - array[1]
8
- return result
9
- }
10
- }
@@ -1,18 +0,0 @@
1
- Contract MetaData() {
2
- @using(preapprovedAssets = true, assetsInContract = false)
3
- pub fn foo() -> () {
4
- transferAlph!(callerAddress!(), callerAddress!(), 1 alph)
5
- return
6
- }
7
-
8
- @using(preapprovedAssets = false, assetsInContract = true)
9
- fn bar() -> () {
10
- transferAlphToSelf!(selfAddress!(), 1 alph)
11
- return
12
- }
13
-
14
- @using(readonly = true)
15
- fn baz() -> () {
16
- return
17
- }
18
- }
@@ -1,8 +0,0 @@
1
- Contract Warnings(@unused a: U256, b: U256) {
2
- const C = 0
3
-
4
- @using(readonly = true)
5
- pub fn foo(@unused x: U256, y: U256) -> () {
6
- return
7
- }
8
- }
package/dev/user.conf DELETED
@@ -1,29 +0,0 @@
1
- // in most cases, modify the following two lines
2
- alephium.genesis.allocations = [{address = "1DrDyTr9RpRsQnDnXo2YRiPzPW4ooHX5LLoqXrqfMrpQH", amount = 1000000000000000000000000, lock-duration = 0 seconds}] // 1 million token allocated for your address
3
- alephium.consensus.num-zeros-at-least-in-hash = 0
4
- alephium.consensus.uncle-dependency-gap-time = 0 seconds
5
- alephium.network.leman-hard-fork-timestamp = 1643500800000 // GMT: 30 January 2022 00:00:00
6
-
7
- alephium.network.network-id = 4
8
- alephium.discovery.bootstrap = []
9
- alephium.wallet.locking-timeout = 99999 minutes
10
- alephium.mempool.auto-mine-for-dev = true
11
- alephium.node.event-log.enabled=true
12
-
13
- alephium.network.rest-port = 22973
14
- alephium.network.ws-port = 21973
15
- alephium.network.miner-api-port = 20973
16
- alephium.api.network-interface = "0.0.0.0"
17
- alephium.api.api-key-enabled = false
18
- alephium.mining.api-interface = "0.0.0.0"
19
- alephium.network.bind-address = "0.0.0.0:19973"
20
- alephium.network.internal-address = "alephium:19973"
21
- alephium.network.coordinator-address = "alephium:19973"
22
-
23
- // arbitrary mining addresses
24
- alephium.mining.miner-addresses = [
25
- "1FsroWmeJPBhcPiUr37pWXdojRBe6jdey9uukEXk1TheA",
26
- "1CQvSXsmM5BMFKguKDPpNUfw1idiut8UifLtT8748JdHc",
27
- "193maApeJWrz9GFwWCfa982ccLARVE9Y1WgKSJaUs7UAx",
28
- "16fZKYPCZJv2TP3FArA9FLUQceTS9U8xVnSjxFG9MBKyY"
29
- ]
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env node
2
- export {};
@@ -1,125 +0,0 @@
1
- #!/usr/bin/env node
2
- "use strict";
3
- /*
4
- Copyright 2018 - 2022 The Alephium Authors
5
- This file is part of the alephium project.
6
-
7
- The library is free software: you can redistribute it and/or modify
8
- it under the terms of the GNU Lesser General Public License as published by
9
- the Free Software Foundation, either version 3 of the License, or
10
- (at your option) any later version.
11
-
12
- The library is distributed in the hope that it will be useful,
13
- but WITHOUT ANY WARRANTY; without even the implied warranty of
14
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
- GNU Lesser General Public License for more details.
16
-
17
- You should have received a copy of the GNU Lesser General Public License
18
- along with the library. If not, see <http://www.gnu.org/licenses/>.
19
- */
20
- var __importDefault = (this && this.__importDefault) || function (mod) {
21
- return (mod && mod.__esModule) ? mod : { "default": mod };
22
- };
23
- Object.defineProperty(exports, "__esModule", { value: true });
24
- const fs_extra_1 = __importDefault(require("fs-extra"));
25
- const process_1 = __importDefault(require("process"));
26
- const path_1 = __importDefault(require("path"));
27
- const find_up_1 = __importDefault(require("find-up"));
28
- const child_process_1 = require("child_process");
29
- const commander_1 = __importDefault(require("commander"));
30
- function getPackageRoot() {
31
- const packageJsonPath = find_up_1.default.sync('package.json', { cwd: path_1.default.dirname(__filename) });
32
- if (packageJsonPath) {
33
- return path_1.default.dirname(packageJsonPath);
34
- }
35
- else {
36
- throw new Error('Cannot find `package.json`');
37
- }
38
- }
39
- function extractProjectType(projectType) {
40
- if (typeof projectType === 'undefined') {
41
- return 'base';
42
- }
43
- else if (['base', 'react'].includes(projectType)) {
44
- return projectType;
45
- }
46
- else {
47
- console.log(`Invalid project type: ${projectType}, expect: base or react`);
48
- process_1.default.exit(1);
49
- }
50
- }
51
- function extractProjectRoot() {
52
- const projectRoot = path_1.default.join(projectParent, projectName);
53
- if (fs_extra_1.default.existsSync(projectRoot)) {
54
- console.log(`Project ${projectName} already exists. Try a different name.`);
55
- console.log();
56
- process_1.default.exit(1);
57
- }
58
- return projectRoot;
59
- }
60
- function copy(dir, files) {
61
- const packageDevDir = path_1.default.join(packageRoot, dir);
62
- const projectDevDir = path_1.default.join(projectRoot, dir);
63
- if (!fs_extra_1.default.existsSync(projectDevDir)) {
64
- fs_extra_1.default.mkdirSync(projectDevDir);
65
- }
66
- for (const file of files) {
67
- fs_extra_1.default.copyFileSync(path_1.default.join(packageDevDir, file), path_1.default.join(projectDevDir, file));
68
- }
69
- }
70
- function prepareShared(packageRoot, projectRoot) {
71
- console.log('Copying files');
72
- console.log(` from ${packageRoot}`);
73
- console.log(` to ${projectRoot}`);
74
- console.log('...');
75
- fs_extra_1.default.copySync(path_1.default.join(packageRoot, 'templates/shared'), projectRoot);
76
- copy('', ['.editorconfig', '.eslintignore', '.gitattributes', 'LICENSE']);
77
- copy('dev', ['user.conf']);
78
- copy('scripts', ['start-devnet.js', 'stop-devnet.js']);
79
- if (fs_extra_1.default.existsSync(path_1.default.join(packageRoot, 'gitignore'))) {
80
- fs_extra_1.default.copySync(path_1.default.join(packageRoot, 'gitignore'), path_1.default.join(projectRoot, '.gitignore'));
81
- }
82
- else {
83
- fs_extra_1.default.copySync(path_1.default.join(packageRoot, '.gitignore'), path_1.default.join(projectRoot, '.gitignore'));
84
- }
85
- console.log();
86
- }
87
- function prepareBase(packageRoot, projectRoot) {
88
- prepareShared(packageRoot, projectRoot);
89
- copy('contracts', ['greeter_main.ral']);
90
- copy('contracts/greeter', ['greeter.ral', 'greeter_interface.ral']);
91
- fs_extra_1.default.copySync(path_1.default.join(packageRoot, 'templates/base'), projectRoot);
92
- }
93
- function prepareReact(packageRoot, projectRoot, projectName) {
94
- console.log('Creating the React app');
95
- (0, child_process_1.execSync)(`npx create-react-app ${projectName} --template typescript`);
96
- prepareShared(packageRoot, projectRoot);
97
- fs_extra_1.default.copySync(path_1.default.join(packageRoot, 'templates/react'), projectRoot);
98
- console.log('Initialize the project');
99
- (0, child_process_1.execSync)('npm install --save-dev react-app-rewired crypto-browserify stream-browserify buffer process eslint-config-prettier eslint-plugin-header eslint-plugin-prettier eslint-plugin-react', { cwd: projectRoot });
100
- (0, child_process_1.execSync)('npm install && npm run prettier', { cwd: projectRoot });
101
- console.log();
102
- }
103
- const program = new commander_1.default.Command('Create sample project')
104
- .arguments('<project-directory>')
105
- .option('-t, --template <path-to-template>', 'specify a template for the project: either base or react')
106
- .parse(process_1.default.argv);
107
- const projectName = program.processedArgs[0];
108
- const projectType = program.opts()['template'];
109
- const packageRoot = getPackageRoot();
110
- const projectParent = process_1.default.cwd();
111
- const projectRoot = extractProjectRoot();
112
- switch (extractProjectType(projectType)) {
113
- case 'base':
114
- prepareBase(packageRoot, projectRoot);
115
- break;
116
- case 'react':
117
- prepareReact(packageRoot, projectRoot, projectName);
118
- break;
119
- }
120
- console.log('✅ Done.');
121
- console.log();
122
- console.log('✨ Project is initialized!');
123
- console.log();
124
- console.log(`Next step: checkout the readme under <${projectName}>`);
125
- console.log();
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};