@alephium/web3 0.41.0 → 0.43.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.
- package/dist/alephium-web3.min.js +1 -1
- package/dist/alephium-web3.min.js.map +1 -1
- package/dist/src/{utils → address}/address.js +15 -19
- package/dist/src/address/index.d.ts +1 -0
- package/dist/src/address/index.js +34 -0
- package/dist/src/api/node-provider.js +10 -9
- package/dist/src/api/types.js +1 -1
- package/dist/src/codec/array-codec.d.ts +2 -3
- package/dist/src/codec/array-codec.js +1 -2
- package/dist/src/codec/asset-output-codec.d.ts +3 -4
- package/dist/src/codec/asset-output-codec.js +10 -12
- package/dist/src/codec/bigint-codec.d.ts +2 -3
- package/dist/src/codec/bigint-codec.js +2 -3
- package/dist/src/codec/bytestring-codec.d.ts +5 -6
- package/dist/src/codec/bytestring-codec.js +5 -5
- package/dist/src/codec/codec.d.ts +2 -3
- package/dist/src/codec/compact-int-codec.d.ts +12 -13
- package/dist/src/codec/compact-int-codec.js +22 -22
- package/dist/src/codec/contract-codec.d.ts +5 -6
- package/dist/src/codec/contract-codec.js +24 -24
- package/dist/src/codec/contract-output-codec.d.ts +2 -3
- package/dist/src/codec/contract-output-codec.js +8 -10
- package/dist/src/codec/contract-output-ref-codec.d.ts +3 -4
- package/dist/src/codec/contract-output-ref-codec.js +2 -2
- package/dist/src/codec/either-codec.d.ts +2 -3
- package/dist/src/codec/either-codec.js +1 -2
- package/dist/src/codec/hash.d.ts +2 -3
- package/dist/src/codec/hash.js +17 -0
- package/dist/src/codec/input-codec.d.ts +3 -4
- package/dist/src/codec/input-codec.js +6 -6
- package/dist/src/codec/instr-codec.d.ts +2 -3
- package/dist/src/codec/instr-codec.js +1 -2
- package/dist/src/codec/lockup-script-codec.d.ts +5 -6
- package/dist/src/codec/lockup-script-codec.js +1 -2
- package/dist/src/codec/long-codec.d.ts +2 -3
- package/dist/src/codec/long-codec.js +1 -2
- package/dist/src/codec/method-codec.d.ts +2 -3
- package/dist/src/codec/method-codec.js +1 -2
- package/dist/src/codec/option-codec.d.ts +3 -4
- package/dist/src/codec/option-codec.js +2 -3
- package/dist/src/codec/script-codec.d.ts +4 -5
- package/dist/src/codec/script-codec.js +1 -3
- package/dist/src/codec/signature-codec.d.ts +3 -4
- package/dist/src/codec/signature-codec.js +17 -0
- package/dist/src/codec/signed-int-codec.d.ts +2 -3
- package/dist/src/codec/signed-int-codec.js +1 -2
- package/dist/src/codec/token-codec.d.ts +3 -4
- package/dist/src/codec/token-codec.js +3 -3
- package/dist/src/codec/transaction-codec.d.ts +4 -5
- package/dist/src/codec/transaction-codec.js +12 -13
- package/dist/src/codec/unlock-script-codec.d.ts +5 -6
- package/dist/src/codec/unlock-script-codec.js +14 -15
- package/dist/src/codec/unsigned-tx-codec.d.ts +4 -5
- package/dist/src/codec/unsigned-tx-codec.js +4 -5
- package/dist/src/contract/contract.d.ts +8 -95
- package/dist/src/contract/contract.js +31 -564
- package/dist/src/contract/ralph.d.ts +1 -1
- package/dist/src/contract/ralph.js +9 -10
- package/dist/src/{utils → exchange}/exchange.js +5 -5
- package/dist/src/exchange/index.d.ts +1 -0
- package/dist/src/exchange/index.js +25 -0
- package/dist/src/index.d.ts +2 -0
- package/dist/src/index.js +2 -0
- package/dist/src/signer/signer.js +4 -5
- package/dist/src/signer/tx-builder.js +3 -3
- package/dist/src/transaction/index.d.ts +1 -0
- package/dist/src/transaction/index.js +1 -0
- package/dist/src/transaction/utils.d.ts +2 -0
- package/dist/src/transaction/utils.js +34 -0
- package/dist/src/utils/index.d.ts +0 -2
- package/dist/src/utils/index.js +0 -7
- package/dist/src/utils/sign.js +1 -1
- package/dist/src/utils/utils.d.ts +1 -0
- package/dist/src/utils/utils.js +30 -11
- package/dist/src/utils/webcrypto.js +3 -4
- package/package.json +1 -2
- package/src/{utils → address}/address.ts +15 -19
- package/src/address/index.ts +19 -0
- package/src/api/node-provider.ts +2 -9
- package/src/api/types.ts +2 -2
- package/src/codec/array-codec.ts +3 -4
- package/src/codec/asset-output-codec.ts +16 -18
- package/src/codec/bigint-codec.ts +4 -5
- package/src/codec/bytestring-codec.ts +8 -8
- package/src/codec/codec.ts +2 -3
- package/src/codec/compact-int-codec.ts +36 -37
- package/src/codec/contract-codec.ts +28 -27
- package/src/codec/contract-output-codec.ts +11 -13
- package/src/codec/contract-output-ref-codec.ts +5 -5
- package/src/codec/either-codec.ts +3 -4
- package/src/codec/hash.ts +2 -3
- package/src/codec/input-codec.ts +10 -10
- package/src/codec/instr-codec.ts +3 -4
- package/src/codec/lockup-script-codec.ts +8 -9
- package/src/codec/long-codec.ts +3 -4
- package/src/codec/method-codec.ts +3 -4
- package/src/codec/option-codec.ts +4 -5
- package/src/codec/script-codec.ts +5 -7
- package/src/codec/signature-codec.ts +3 -4
- package/src/codec/signed-int-codec.ts +3 -4
- package/src/codec/token-codec.ts +6 -6
- package/src/codec/transaction-codec.ts +17 -18
- package/src/codec/unlock-script-codec.ts +26 -27
- package/src/codec/unsigned-tx-codec.ts +10 -11
- package/src/contract/contract.ts +18 -790
- package/src/contract/ralph.ts +10 -11
- package/src/{utils → exchange}/exchange.ts +3 -11
- package/src/exchange/index.ts +19 -0
- package/src/index.ts +2 -0
- package/src/signer/signer.ts +2 -3
- package/src/signer/tx-builder.ts +2 -2
- package/src/transaction/index.ts +1 -0
- package/src/transaction/utils.ts +38 -0
- package/src/utils/index.ts +0 -2
- package/src/utils/sign.ts +1 -1
- package/src/utils/utils.ts +29 -10
- package/src/utils/webcrypto.ts +3 -4
- package/webpack.config.js +1 -6
- package/dist/src/utils/error.d.ts +0 -15
- package/dist/src/utils/error.js +0 -66
- package/src/utils/error.ts +0 -77
- /package/dist/src/{utils → address}/address.d.ts +0 -0
- /package/dist/src/{utils → exchange}/exchange.d.ts +0 -0
|
@@ -15,10 +15,9 @@ GNU Lesser General Public License for more details.
|
|
|
15
15
|
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
|
-
import { Buffer } from 'buffer/'
|
|
19
18
|
import { Parser } from 'binary-parser'
|
|
20
19
|
import { UnsignedTx as ApiUnsignedTx } from '../api/api-alephium'
|
|
21
|
-
import { binToHex, hexToBinUnsafe } from '../utils'
|
|
20
|
+
import { binToHex, concatBytes, hexToBinUnsafe } from '../utils'
|
|
22
21
|
import { DecodedScript, scriptCodec, statefulScriptCodecOpt } from './script-codec'
|
|
23
22
|
import { Option } from './option-codec'
|
|
24
23
|
import { DecodedCompactInt, compactSignedIntCodec, compactUnsignedIntCodec } from './compact-int-codec'
|
|
@@ -58,9 +57,9 @@ export class UnsignedTxCodec implements Codec<UnsignedTx> {
|
|
|
58
57
|
type: assetOutputsCodec.parser
|
|
59
58
|
})
|
|
60
59
|
|
|
61
|
-
encode(decodedUnsignedTx: UnsignedTx):
|
|
62
|
-
return
|
|
63
|
-
|
|
60
|
+
encode(decodedUnsignedTx: UnsignedTx): Uint8Array {
|
|
61
|
+
return concatBytes([
|
|
62
|
+
new Uint8Array([decodedUnsignedTx.version, decodedUnsignedTx.networkId]),
|
|
64
63
|
statefulScriptCodecOpt.encode(decodedUnsignedTx.statefulScript),
|
|
65
64
|
compactSignedIntCodec.encode(decodedUnsignedTx.gasAmount),
|
|
66
65
|
compactUnsignedIntCodec.encode(decodedUnsignedTx.gasPrice),
|
|
@@ -69,16 +68,16 @@ export class UnsignedTxCodec implements Codec<UnsignedTx> {
|
|
|
69
68
|
])
|
|
70
69
|
}
|
|
71
70
|
|
|
72
|
-
decode(input:
|
|
71
|
+
decode(input: Uint8Array): UnsignedTx {
|
|
73
72
|
return this.parser.parse(input)
|
|
74
73
|
}
|
|
75
74
|
|
|
76
|
-
encodeApiUnsignedTx(input: ApiUnsignedTx):
|
|
75
|
+
encodeApiUnsignedTx(input: ApiUnsignedTx): Uint8Array {
|
|
77
76
|
const decoded = UnsignedTxCodec.fromApiUnsignedTx(input)
|
|
78
77
|
return this.encode(decoded)
|
|
79
78
|
}
|
|
80
79
|
|
|
81
|
-
decodeApiUnsignedTx(input:
|
|
80
|
+
decodeApiUnsignedTx(input: Uint8Array): ApiUnsignedTx {
|
|
82
81
|
const decoded = this.parser.parse(input)
|
|
83
82
|
return UnsignedTxCodec.toApiUnsignedTx(decoded)
|
|
84
83
|
}
|
|
@@ -98,7 +97,7 @@ export class UnsignedTxCodec implements Codec<UnsignedTx> {
|
|
|
98
97
|
const fixedOutputs = AssetOutputCodec.toFixedAssetOutputs(txIdBytes, unsigned.fixedOutputs.value)
|
|
99
98
|
let scriptOpt: string | undefined = undefined
|
|
100
99
|
if (unsigned.statefulScript.option === 1) {
|
|
101
|
-
scriptOpt = scriptCodec.encode(unsigned.statefulScript.value!)
|
|
100
|
+
scriptOpt = binToHex(scriptCodec.encode(unsigned.statefulScript.value!))
|
|
102
101
|
}
|
|
103
102
|
|
|
104
103
|
return { txId, version, networkId, gasAmount, scriptOpt, gasPrice, inputs, fixedOutputs }
|
|
@@ -113,8 +112,8 @@ export class UnsignedTxCodec implements Codec<UnsignedTx> {
|
|
|
113
112
|
const inputs = inputsCodec.fromArray(inputsValue)
|
|
114
113
|
const fixedOutputsValue = AssetOutputCodec.fromFixedAssetOutputs(unsignedTx.fixedOutputs)
|
|
115
114
|
const fixedOutputs = assetOutputsCodec.fromArray(fixedOutputsValue)
|
|
116
|
-
const statefulScript = statefulScriptCodecOpt.
|
|
117
|
-
unsignedTx.scriptOpt ?
|
|
115
|
+
const statefulScript = statefulScriptCodecOpt.fromBytes(
|
|
116
|
+
unsignedTx.scriptOpt ? hexToBinUnsafe(unsignedTx.scriptOpt) : undefined
|
|
118
117
|
)
|
|
119
118
|
|
|
120
119
|
return { version, networkId, gasAmount, gasPrice, inputs, fixedOutputs, statefulScript }
|