lunesjs 1.5.9 → 1.5.12
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/lib/client/transactions/BaseTransaction.d.ts +6 -0
- package/lib/client/transactions/BaseTransaction.js +2 -0
- package/{dist → lib}/client/transactions/transactions.types.d.ts +0 -0
- package/lib/client/transactions/transactions.types.js +27 -0
- package/lib/client/transactions/transfer/service.transfer.d.ts +21 -0
- package/lib/client/transactions/transfer/service.transfer.js +153 -0
- package/lib/client/transactions/transfer/transfer.types.d.ts +12 -0
- package/lib/client/transactions/transfer/transfer.types.js +2 -0
- package/lib/client/transactions/transfer/validator.d.ts +22 -0
- package/lib/client/transactions/transfer/validator.js +176 -0
- package/lib/client/wallet/constants.d.ts +8 -0
- package/{dist → lib}/client/wallet/constants.js +9 -9
- package/lib/client/wallet/service.account.d.ts +28 -0
- package/lib/client/wallet/service.account.js +83 -0
- package/lib/client/wallet/wallet.types.d.ts +21 -0
- package/lib/client/wallet/wallet.types.js +11 -0
- package/lib/index.d.ts +5 -0
- package/lib/index.js +24 -0
- package/{dist → lib}/utils/crypto.d.ts +24 -12
- package/lib/utils/crypto.js +147 -0
- package/package.json +11 -11
- package/CHANGELOG.md +0 -3
- package/dist/client/transactions/BaseTransaction.d.ts +0 -6
- package/dist/client/transactions/BaseTransaction.js +0 -2
- package/dist/client/transactions/transactions.types.js +0 -17
- package/dist/client/transactions/transfer/service.transfer.d.ts +0 -12
- package/dist/client/transactions/transfer/service.transfer.js +0 -78
- package/dist/client/transactions/transfer/transfer.types.d.ts +0 -12
- package/dist/client/transactions/transfer/transfer.types.js +0 -2
- package/dist/client/transactions/transfer/validator.d.ts +0 -9
- package/dist/client/transactions/transfer/validator.js +0 -93
- package/dist/client/wallet/constants.d.ts +0 -8
- package/dist/client/wallet/service.account.d.ts +0 -20
- package/dist/client/wallet/service.account.js +0 -35
- package/dist/client/wallet/wallet.types.d.ts +0 -21
- package/dist/client/wallet/wallet.types.js +0 -11
- package/dist/index.d.ts +0 -5
- package/dist/index.js +0 -14
- package/dist/utils/crypto.js +0 -102
File without changes
|
@@ -0,0 +1,27 @@
|
|
1
|
+
"use strict"
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true })
|
3
|
+
exports.TransactionsTypes = void 0
|
4
|
+
var TransactionsTypes
|
5
|
+
;(function (TransactionsTypes) {
|
6
|
+
let TransferToken
|
7
|
+
;(function (TransferToken) {
|
8
|
+
TransferToken[(TransferToken["int"] = 4)] = "int"
|
9
|
+
TransferToken[(TransferToken["fee"] = 1000000)] = "fee"
|
10
|
+
})(
|
11
|
+
(TransferToken =
|
12
|
+
TransactionsTypes.TransferToken ||
|
13
|
+
(TransactionsTypes.TransferToken = {}))
|
14
|
+
)
|
15
|
+
let IssueToken
|
16
|
+
;(function (IssueToken) {
|
17
|
+
IssueToken[(IssueToken["int"] = 5)] = "int"
|
18
|
+
IssueToken[(IssueToken["fee"] = 1000000000)] = "fee"
|
19
|
+
})(
|
20
|
+
(IssueToken =
|
21
|
+
TransactionsTypes.IssueToken || (TransactionsTypes.IssueToken = {}))
|
22
|
+
)
|
23
|
+
//...
|
24
|
+
})(
|
25
|
+
(TransactionsTypes =
|
26
|
+
exports.TransactionsTypes || (exports.TransactionsTypes = {}))
|
27
|
+
)
|
@@ -0,0 +1,21 @@
|
|
1
|
+
import { WalletTypes } from "../../wallet/wallet.types"
|
2
|
+
import { BaseTransaction } from "../BaseTransaction"
|
3
|
+
import { ITransfer } from "./transfer.types"
|
4
|
+
declare class TransferToken implements BaseTransaction {
|
5
|
+
private tx
|
6
|
+
constructor(tx: ITransfer)
|
7
|
+
transaction(): ITransfer
|
8
|
+
sign(privateKey: WalletTypes.PrivateKey): ITransfer
|
9
|
+
send(): Promise<void>
|
10
|
+
}
|
11
|
+
export declare function transferTokenFactory(
|
12
|
+
senderPublicKey: string,
|
13
|
+
recipient: string,
|
14
|
+
amount: number,
|
15
|
+
assetId?: string,
|
16
|
+
chain?: WalletTypes.Chain,
|
17
|
+
timestamp?: number,
|
18
|
+
feeAsset?: string,
|
19
|
+
fee?: number
|
20
|
+
): TransferToken
|
21
|
+
export {}
|
@@ -0,0 +1,153 @@
|
|
1
|
+
"use strict"
|
2
|
+
var __createBinding =
|
3
|
+
(this && this.__createBinding) ||
|
4
|
+
(Object.create
|
5
|
+
? function (o, m, k, k2) {
|
6
|
+
if (k2 === undefined) k2 = k
|
7
|
+
var desc = Object.getOwnPropertyDescriptor(m, k)
|
8
|
+
if (
|
9
|
+
!desc ||
|
10
|
+
("get" in desc
|
11
|
+
? !m.__esModule
|
12
|
+
: desc.writable || desc.configurable)
|
13
|
+
) {
|
14
|
+
desc = {
|
15
|
+
enumerable: true,
|
16
|
+
get: function () {
|
17
|
+
return m[k]
|
18
|
+
}
|
19
|
+
}
|
20
|
+
}
|
21
|
+
Object.defineProperty(o, k2, desc)
|
22
|
+
}
|
23
|
+
: function (o, m, k, k2) {
|
24
|
+
if (k2 === undefined) k2 = k
|
25
|
+
o[k2] = m[k]
|
26
|
+
})
|
27
|
+
var __setModuleDefault =
|
28
|
+
(this && this.__setModuleDefault) ||
|
29
|
+
(Object.create
|
30
|
+
? function (o, v) {
|
31
|
+
Object.defineProperty(o, "default", {
|
32
|
+
enumerable: true,
|
33
|
+
value: v
|
34
|
+
})
|
35
|
+
}
|
36
|
+
: function (o, v) {
|
37
|
+
o["default"] = v
|
38
|
+
})
|
39
|
+
var __importStar =
|
40
|
+
(this && this.__importStar) ||
|
41
|
+
function (mod) {
|
42
|
+
if (mod && mod.__esModule) return mod
|
43
|
+
var result = {}
|
44
|
+
if (mod != null)
|
45
|
+
for (var k in mod)
|
46
|
+
if (
|
47
|
+
k !== "default" &&
|
48
|
+
Object.prototype.hasOwnProperty.call(mod, k)
|
49
|
+
)
|
50
|
+
__createBinding(result, mod, k)
|
51
|
+
__setModuleDefault(result, mod)
|
52
|
+
return result
|
53
|
+
}
|
54
|
+
var __awaiter =
|
55
|
+
(this && this.__awaiter) ||
|
56
|
+
function (thisArg, _arguments, P, generator) {
|
57
|
+
function adopt(value) {
|
58
|
+
return value instanceof P
|
59
|
+
? value
|
60
|
+
: new P(function (resolve) {
|
61
|
+
resolve(value)
|
62
|
+
})
|
63
|
+
}
|
64
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
65
|
+
function fulfilled(value) {
|
66
|
+
try {
|
67
|
+
step(generator.next(value))
|
68
|
+
} catch (e) {
|
69
|
+
reject(e)
|
70
|
+
}
|
71
|
+
}
|
72
|
+
function rejected(value) {
|
73
|
+
try {
|
74
|
+
step(generator["throw"](value))
|
75
|
+
} catch (e) {
|
76
|
+
reject(e)
|
77
|
+
}
|
78
|
+
}
|
79
|
+
function step(result) {
|
80
|
+
result.done
|
81
|
+
? resolve(result.value)
|
82
|
+
: adopt(result.value).then(fulfilled, rejected)
|
83
|
+
}
|
84
|
+
step(
|
85
|
+
(generator = generator.apply(thisArg, _arguments || [])).next()
|
86
|
+
)
|
87
|
+
})
|
88
|
+
}
|
89
|
+
var __importDefault =
|
90
|
+
(this && this.__importDefault) ||
|
91
|
+
function (mod) {
|
92
|
+
return mod && mod.__esModule ? mod : { default: mod }
|
93
|
+
}
|
94
|
+
Object.defineProperty(exports, "__esModule", { value: true })
|
95
|
+
exports.transferTokenFactory = void 0
|
96
|
+
const transactions_types_1 = require("../transactions.types")
|
97
|
+
const wallet_types_1 = require("../../wallet/wallet.types")
|
98
|
+
const validator_1 = __importDefault(require("./validator"))
|
99
|
+
const wasm = __importStar(require("lunesrs"))
|
100
|
+
class TransferToken {
|
101
|
+
constructor(tx) {
|
102
|
+
this.tx = tx
|
103
|
+
}
|
104
|
+
transaction() {
|
105
|
+
return this.tx
|
106
|
+
}
|
107
|
+
sign(privateKey) {
|
108
|
+
this.tx.signature = validator_1.default.sign(privateKey, this.tx)
|
109
|
+
return this.tx
|
110
|
+
}
|
111
|
+
send() {
|
112
|
+
return __awaiter(this, void 0, void 0, function* () {
|
113
|
+
validator_1.default.send(this.tx)
|
114
|
+
})
|
115
|
+
}
|
116
|
+
}
|
117
|
+
function transferTokenFactory(
|
118
|
+
senderPublicKey,
|
119
|
+
recipient,
|
120
|
+
amount,
|
121
|
+
assetId,
|
122
|
+
chain,
|
123
|
+
timestamp,
|
124
|
+
feeAsset,
|
125
|
+
fee
|
126
|
+
) {
|
127
|
+
const chain_id =
|
128
|
+
chain != undefined ? chain : wallet_types_1.WalletTypes.Chain.Mainnet
|
129
|
+
if (
|
130
|
+
false ==
|
131
|
+
validator_1.default.ready(senderPublicKey, recipient, amount, chain_id)
|
132
|
+
) {
|
133
|
+
throw new Error("dados invalidos")
|
134
|
+
}
|
135
|
+
return new TransferToken({
|
136
|
+
senderPublicKey: senderPublicKey,
|
137
|
+
recipient: recipient,
|
138
|
+
amount: amount,
|
139
|
+
sender: wasm.arrayToBase58(
|
140
|
+
wasm.toAddress(1, chain_id, wasm.base58ToArray(senderPublicKey))
|
141
|
+
),
|
142
|
+
timestamp: timestamp != undefined ? timestamp : new Date().getTime(),
|
143
|
+
feeAsset: feeAsset != undefined ? feeAsset : "",
|
144
|
+
assetId: assetId != undefined ? assetId : "",
|
145
|
+
type: transactions_types_1.TransactionsTypes.TransferToken.int,
|
146
|
+
fee:
|
147
|
+
fee != undefined
|
148
|
+
? fee
|
149
|
+
: transactions_types_1.TransactionsTypes.TransferToken.fee,
|
150
|
+
signature: ""
|
151
|
+
})
|
152
|
+
}
|
153
|
+
exports.transferTokenFactory = transferTokenFactory
|
@@ -0,0 +1,22 @@
|
|
1
|
+
import { WalletTypes } from "../../wallet/wallet.types"
|
2
|
+
import { ITransfer } from "./transfer.types"
|
3
|
+
declare const validator: {
|
4
|
+
serialize: (
|
5
|
+
senderPublicKey: string,
|
6
|
+
assetId: string,
|
7
|
+
feeAsset: string,
|
8
|
+
timestamp: number,
|
9
|
+
amount: number,
|
10
|
+
fee: number,
|
11
|
+
recipient: string
|
12
|
+
) => Uint8Array
|
13
|
+
ready: (
|
14
|
+
senderPublicKey: string,
|
15
|
+
recipient: string,
|
16
|
+
amount: number,
|
17
|
+
chain: WalletTypes.Chain
|
18
|
+
) => boolean
|
19
|
+
sign: (privateKey: WalletTypes.PrivateKey, tx: ITransfer) => string
|
20
|
+
send: (tx: ITransfer) => Promise<void>
|
21
|
+
}
|
22
|
+
export default validator
|
@@ -0,0 +1,176 @@
|
|
1
|
+
"use strict"
|
2
|
+
var __createBinding =
|
3
|
+
(this && this.__createBinding) ||
|
4
|
+
(Object.create
|
5
|
+
? function (o, m, k, k2) {
|
6
|
+
if (k2 === undefined) k2 = k
|
7
|
+
var desc = Object.getOwnPropertyDescriptor(m, k)
|
8
|
+
if (
|
9
|
+
!desc ||
|
10
|
+
("get" in desc
|
11
|
+
? !m.__esModule
|
12
|
+
: desc.writable || desc.configurable)
|
13
|
+
) {
|
14
|
+
desc = {
|
15
|
+
enumerable: true,
|
16
|
+
get: function () {
|
17
|
+
return m[k]
|
18
|
+
}
|
19
|
+
}
|
20
|
+
}
|
21
|
+
Object.defineProperty(o, k2, desc)
|
22
|
+
}
|
23
|
+
: function (o, m, k, k2) {
|
24
|
+
if (k2 === undefined) k2 = k
|
25
|
+
o[k2] = m[k]
|
26
|
+
})
|
27
|
+
var __setModuleDefault =
|
28
|
+
(this && this.__setModuleDefault) ||
|
29
|
+
(Object.create
|
30
|
+
? function (o, v) {
|
31
|
+
Object.defineProperty(o, "default", {
|
32
|
+
enumerable: true,
|
33
|
+
value: v
|
34
|
+
})
|
35
|
+
}
|
36
|
+
: function (o, v) {
|
37
|
+
o["default"] = v
|
38
|
+
})
|
39
|
+
var __importStar =
|
40
|
+
(this && this.__importStar) ||
|
41
|
+
function (mod) {
|
42
|
+
if (mod && mod.__esModule) return mod
|
43
|
+
var result = {}
|
44
|
+
if (mod != null)
|
45
|
+
for (var k in mod)
|
46
|
+
if (
|
47
|
+
k !== "default" &&
|
48
|
+
Object.prototype.hasOwnProperty.call(mod, k)
|
49
|
+
)
|
50
|
+
__createBinding(result, mod, k)
|
51
|
+
__setModuleDefault(result, mod)
|
52
|
+
return result
|
53
|
+
}
|
54
|
+
var __awaiter =
|
55
|
+
(this && this.__awaiter) ||
|
56
|
+
function (thisArg, _arguments, P, generator) {
|
57
|
+
function adopt(value) {
|
58
|
+
return value instanceof P
|
59
|
+
? value
|
60
|
+
: new P(function (resolve) {
|
61
|
+
resolve(value)
|
62
|
+
})
|
63
|
+
}
|
64
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
65
|
+
function fulfilled(value) {
|
66
|
+
try {
|
67
|
+
step(generator.next(value))
|
68
|
+
} catch (e) {
|
69
|
+
reject(e)
|
70
|
+
}
|
71
|
+
}
|
72
|
+
function rejected(value) {
|
73
|
+
try {
|
74
|
+
step(generator["throw"](value))
|
75
|
+
} catch (e) {
|
76
|
+
reject(e)
|
77
|
+
}
|
78
|
+
}
|
79
|
+
function step(result) {
|
80
|
+
result.done
|
81
|
+
? resolve(result.value)
|
82
|
+
: adopt(result.value).then(fulfilled, rejected)
|
83
|
+
}
|
84
|
+
step(
|
85
|
+
(generator = generator.apply(thisArg, _arguments || [])).next()
|
86
|
+
)
|
87
|
+
})
|
88
|
+
}
|
89
|
+
var __importDefault =
|
90
|
+
(this && this.__importDefault) ||
|
91
|
+
function (mod) {
|
92
|
+
return mod && mod.__esModule ? mod : { default: mod }
|
93
|
+
}
|
94
|
+
Object.defineProperty(exports, "__esModule", { value: true })
|
95
|
+
const transactions_types_1 = require("../transactions.types")
|
96
|
+
const crypto_1 = __importDefault(require("../../../utils/crypto"))
|
97
|
+
const wasm = __importStar(require("lunesrs"))
|
98
|
+
const axios_1 = __importDefault(require("axios"))
|
99
|
+
const validator = {
|
100
|
+
serialize: (
|
101
|
+
senderPublicKey,
|
102
|
+
assetId,
|
103
|
+
feeAsset,
|
104
|
+
timestamp,
|
105
|
+
amount,
|
106
|
+
fee,
|
107
|
+
recipient
|
108
|
+
) => {
|
109
|
+
const tokenId =
|
110
|
+
assetId != ""
|
111
|
+
? new Uint8Array([1, ...wasm.base58ToArray(assetId)])
|
112
|
+
: new Uint8Array([0])
|
113
|
+
const tokenFee =
|
114
|
+
feeAsset != ""
|
115
|
+
? new Uint8Array([1, ...wasm.base58ToArray(feeAsset)])
|
116
|
+
: new Uint8Array([0])
|
117
|
+
return new Uint8Array([
|
118
|
+
...[transactions_types_1.TransactionsTypes.TransferToken.int],
|
119
|
+
...wasm.base58ToArray(senderPublicKey),
|
120
|
+
...tokenId,
|
121
|
+
...tokenFee,
|
122
|
+
...wasm.serializeUInteger(BigInt(timestamp)),
|
123
|
+
...wasm.serializeUInteger(BigInt(amount)),
|
124
|
+
...wasm.serializeUInteger(BigInt(fee)),
|
125
|
+
...wasm.base58ToArray(recipient)
|
126
|
+
])
|
127
|
+
},
|
128
|
+
ready: (senderPublicKey, recipient, amount, chain) => {
|
129
|
+
const sender = wasm.arrayToBase58(
|
130
|
+
wasm.toAddress(1, chain, wasm.base58ToArray(senderPublicKey))
|
131
|
+
)
|
132
|
+
if (amount <= 0) {
|
133
|
+
return false
|
134
|
+
} else if (
|
135
|
+
!(
|
136
|
+
crypto_1.default.validateAddress(sender, chain) === true &&
|
137
|
+
crypto_1.default.validateAddress(recipient, chain) === true
|
138
|
+
)
|
139
|
+
) {
|
140
|
+
return false
|
141
|
+
} else {
|
142
|
+
return true
|
143
|
+
}
|
144
|
+
},
|
145
|
+
sign: (privateKey, tx) => {
|
146
|
+
const message = validator.serialize(
|
147
|
+
tx.senderPublicKey,
|
148
|
+
tx.assetId,
|
149
|
+
tx.feeAsset,
|
150
|
+
tx.timestamp,
|
151
|
+
tx.amount,
|
152
|
+
tx.fee,
|
153
|
+
tx.recipient
|
154
|
+
)
|
155
|
+
return crypto_1.default.fastSignature(
|
156
|
+
privateKey,
|
157
|
+
wasm.arrayToBase58(new Uint8Array(message))
|
158
|
+
)
|
159
|
+
},
|
160
|
+
send: (tx) =>
|
161
|
+
__awaiter(void 0, void 0, void 0, function* () {
|
162
|
+
yield axios_1.default
|
163
|
+
.request({
|
164
|
+
url: "https://lunesnode.lunes.io/transactions/broadcast",
|
165
|
+
method: "post",
|
166
|
+
data: tx
|
167
|
+
})
|
168
|
+
.then((x) => {
|
169
|
+
console.log(x)
|
170
|
+
})
|
171
|
+
.catch((error) => {
|
172
|
+
console.error(error.response.data)
|
173
|
+
})
|
174
|
+
})
|
175
|
+
}
|
176
|
+
exports.default = validator
|
@@ -1,9 +1,9 @@
|
|
1
|
-
"use strict"
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true })
|
3
|
-
const addressVersion = 1
|
4
|
-
const addressChecksumLength = 4
|
5
|
-
const addressHashLength = 20
|
6
|
-
const addressLength = 1 + 1 + addressChecksumLength + addressHashLength
|
1
|
+
"use strict"
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true })
|
3
|
+
const addressVersion = 1
|
4
|
+
const addressChecksumLength = 4
|
5
|
+
const addressHashLength = 20
|
6
|
+
const addressLength = 1 + 1 + addressChecksumLength + addressHashLength
|
7
7
|
const wordsList = [
|
8
8
|
"abandon",
|
9
9
|
"ability",
|
@@ -2053,12 +2053,12 @@ const wordsList = [
|
|
2053
2053
|
"zero",
|
2054
2054
|
"zone",
|
2055
2055
|
"zoo"
|
2056
|
-
]
|
2056
|
+
]
|
2057
2057
|
const walletConstants = {
|
2058
2058
|
addressVersion,
|
2059
2059
|
addressChecksumLength,
|
2060
2060
|
addressHashLength,
|
2061
2061
|
addressLength,
|
2062
2062
|
wordsList
|
2063
|
-
}
|
2064
|
-
exports.default = walletConstants
|
2063
|
+
}
|
2064
|
+
exports.default = walletConstants
|
@@ -0,0 +1,28 @@
|
|
1
|
+
import { IAccount } from "./wallet.types"
|
2
|
+
declare class Account implements IAccount {
|
3
|
+
privateKey: string
|
4
|
+
publicKey: string
|
5
|
+
address: string
|
6
|
+
chain: number
|
7
|
+
nonce: number
|
8
|
+
seed: string
|
9
|
+
constructor(wallet: IAccount)
|
10
|
+
}
|
11
|
+
export declare function accountFactory({
|
12
|
+
privateKey,
|
13
|
+
publicKey,
|
14
|
+
address,
|
15
|
+
nWords,
|
16
|
+
chain,
|
17
|
+
nonce,
|
18
|
+
seed
|
19
|
+
}?: {
|
20
|
+
privateKey?: string
|
21
|
+
publicKey?: string
|
22
|
+
address?: string
|
23
|
+
nWords?: number
|
24
|
+
chain?: number
|
25
|
+
nonce?: number
|
26
|
+
seed?: string
|
27
|
+
}): Account
|
28
|
+
export {}
|
@@ -0,0 +1,83 @@
|
|
1
|
+
"use strict"
|
2
|
+
var __importDefault =
|
3
|
+
(this && this.__importDefault) ||
|
4
|
+
function (mod) {
|
5
|
+
return mod && mod.__esModule ? mod : { default: mod }
|
6
|
+
}
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true })
|
8
|
+
exports.accountFactory = void 0
|
9
|
+
const crypto_1 = __importDefault(require("../../utils/crypto"))
|
10
|
+
class Account {
|
11
|
+
constructor(wallet) {
|
12
|
+
this.privateKey = wallet.privateKey
|
13
|
+
this.publicKey = wallet.publicKey
|
14
|
+
this.address = wallet.address
|
15
|
+
this.chain = wallet.chain
|
16
|
+
this.nonce = wallet.nonce
|
17
|
+
this.seed = wallet.seed
|
18
|
+
}
|
19
|
+
}
|
20
|
+
function accountFactory({
|
21
|
+
privateKey,
|
22
|
+
publicKey,
|
23
|
+
address,
|
24
|
+
nWords,
|
25
|
+
chain,
|
26
|
+
nonce,
|
27
|
+
seed
|
28
|
+
} = {}) {
|
29
|
+
if (seed != undefined) {
|
30
|
+
return new Account(
|
31
|
+
Object.assign(
|
32
|
+
{},
|
33
|
+
crypto_1.default.fromExistingSeed(
|
34
|
+
seed,
|
35
|
+
nonce != undefined ? nonce : 0,
|
36
|
+
chain != undefined ? chain : 1
|
37
|
+
)
|
38
|
+
)
|
39
|
+
)
|
40
|
+
} else if (privateKey != undefined) {
|
41
|
+
return new Account(
|
42
|
+
Object.assign(
|
43
|
+
{},
|
44
|
+
crypto_1.default.fromPrivateKey(
|
45
|
+
privateKey,
|
46
|
+
chain != undefined ? chain : 1
|
47
|
+
)
|
48
|
+
)
|
49
|
+
)
|
50
|
+
} else if (publicKey != undefined) {
|
51
|
+
return new Account(
|
52
|
+
Object.assign(
|
53
|
+
{},
|
54
|
+
crypto_1.default.fromPublicKey(
|
55
|
+
publicKey,
|
56
|
+
chain != undefined ? chain : 1
|
57
|
+
)
|
58
|
+
)
|
59
|
+
)
|
60
|
+
} else if (address != undefined) {
|
61
|
+
return new Account(
|
62
|
+
Object.assign(
|
63
|
+
{},
|
64
|
+
crypto_1.default.fromAddress(
|
65
|
+
address,
|
66
|
+
chain != undefined ? chain : 0
|
67
|
+
)
|
68
|
+
)
|
69
|
+
)
|
70
|
+
} else {
|
71
|
+
return new Account(
|
72
|
+
Object.assign(
|
73
|
+
{},
|
74
|
+
crypto_1.default.fromNewSeed(
|
75
|
+
nWords != undefined ? nWords : 12,
|
76
|
+
nonce != undefined ? nonce : 0,
|
77
|
+
chain != undefined ? chain : 1
|
78
|
+
)
|
79
|
+
)
|
80
|
+
)
|
81
|
+
}
|
82
|
+
}
|
83
|
+
exports.accountFactory = accountFactory
|
@@ -0,0 +1,21 @@
|
|
1
|
+
export declare type empty = ""
|
2
|
+
export declare type zero = 0
|
3
|
+
export declare namespace WalletTypes {
|
4
|
+
type Seed = string | empty
|
5
|
+
type Nonce = number | zero
|
6
|
+
enum Chain {
|
7
|
+
Mainnet = 1,
|
8
|
+
Testnet = 0
|
9
|
+
}
|
10
|
+
type PrivateKey = string | empty
|
11
|
+
type PublicKey = string | empty
|
12
|
+
type Address = string | empty
|
13
|
+
}
|
14
|
+
export interface IAccount {
|
15
|
+
privateKey: WalletTypes.PrivateKey
|
16
|
+
publicKey: WalletTypes.PublicKey
|
17
|
+
address: WalletTypes.Address
|
18
|
+
nonce: WalletTypes.Nonce
|
19
|
+
chain: WalletTypes.Chain
|
20
|
+
seed: WalletTypes.Seed
|
21
|
+
}
|
@@ -0,0 +1,11 @@
|
|
1
|
+
"use strict"
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true })
|
3
|
+
exports.WalletTypes = void 0
|
4
|
+
var WalletTypes
|
5
|
+
;(function (WalletTypes) {
|
6
|
+
let Chain
|
7
|
+
;(function (Chain) {
|
8
|
+
Chain[(Chain["Mainnet"] = 1)] = "Mainnet"
|
9
|
+
Chain[(Chain["Testnet"] = 0)] = "Testnet"
|
10
|
+
})((Chain = WalletTypes.Chain || (WalletTypes.Chain = {})))
|
11
|
+
})((WalletTypes = exports.WalletTypes || (exports.WalletTypes = {})))
|
package/lib/index.d.ts
ADDED
@@ -0,0 +1,5 @@
|
|
1
|
+
export { transferTokenFactory } from "./client/transactions/transfer/service.transfer"
|
2
|
+
export { accountFactory } from "./client/wallet/service.account"
|
3
|
+
export { IAccount } from "./client/wallet/wallet.types"
|
4
|
+
import cryptoUtils from "./utils/crypto"
|
5
|
+
export default cryptoUtils
|
package/lib/index.js
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
"use strict"
|
2
|
+
var __importDefault =
|
3
|
+
(this && this.__importDefault) ||
|
4
|
+
function (mod) {
|
5
|
+
return mod && mod.__esModule ? mod : { default: mod }
|
6
|
+
}
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true })
|
8
|
+
exports.accountFactory = exports.transferTokenFactory = void 0
|
9
|
+
var service_transfer_1 = require("./client/transactions/transfer/service.transfer")
|
10
|
+
Object.defineProperty(exports, "transferTokenFactory", {
|
11
|
+
enumerable: true,
|
12
|
+
get: function () {
|
13
|
+
return service_transfer_1.transferTokenFactory
|
14
|
+
}
|
15
|
+
})
|
16
|
+
var service_account_1 = require("./client/wallet/service.account")
|
17
|
+
Object.defineProperty(exports, "accountFactory", {
|
18
|
+
enumerable: true,
|
19
|
+
get: function () {
|
20
|
+
return service_account_1.accountFactory
|
21
|
+
}
|
22
|
+
})
|
23
|
+
const crypto_1 = __importDefault(require("./utils/crypto"))
|
24
|
+
exports.default = crypto_1.default
|