ton-ledger
Advanced tools
Comparing version
@@ -22,2 +22,25 @@ /// <reference types="node" /> | ||
amount: BN; | ||
} | { | ||
type: 'transfer-ownership'; | ||
queryId: BN | null; | ||
address: Address; | ||
} | { | ||
type: 'create-proposal'; | ||
queryId: BN | null; | ||
id: number | null; | ||
proposal: Cell; | ||
metadata: Cell; | ||
} | { | ||
type: 'vote-proposal'; | ||
queryId: BN | null; | ||
id: number; | ||
vote: 'yes' | 'no' | 'abstain'; | ||
} | { | ||
type: 'execute-proposal'; | ||
queryId: BN | null; | ||
id: number; | ||
} | { | ||
type: 'abort-proposal'; | ||
queryId: BN | null; | ||
id: number; | ||
}; | ||
@@ -24,0 +47,0 @@ export declare class TonTransport { |
@@ -127,4 +127,3 @@ "use strict"; | ||
writeUint64(transaction.amount), | ||
writeUint8(transaction.to.workChain === -1 ? 0xff : transaction.to.workChain), | ||
transaction.to.hash, | ||
writeAddress(transaction.to), | ||
writeUint8(transaction.bounce ? 1 : 0), | ||
@@ -215,3 +214,3 @@ writeUint8(transaction.sendMode), | ||
writeUint8(1), | ||
writeUint32(0x01) | ||
writeUint32(0x02) | ||
]); | ||
@@ -248,3 +247,3 @@ // Build cells and hints | ||
writeUint8(1), | ||
writeUint32(0x01) | ||
writeUint32(0x03) | ||
]); | ||
@@ -282,2 +281,170 @@ // Build cells and hints | ||
} | ||
else if (transaction.payload.type === 'transfer-ownership') { | ||
hints = Buffer.concat([ | ||
writeUint8(1), | ||
writeUint32(0x04) | ||
]); | ||
// Build cells and hints | ||
let b = (0, ton_1.beginCell)() | ||
.storeUint(0x295e75a9, 32); | ||
let d = Buffer.alloc(0); | ||
// Query ID | ||
if (transaction.payload.queryId !== null) { | ||
d = Buffer.concat([d, writeUint8(1), writeUint64(transaction.payload.queryId)]); | ||
b = b.storeUint(transaction.payload.queryId, 64); | ||
} | ||
else { | ||
d = Buffer.concat([d, writeUint8(0)]); | ||
} | ||
// Address | ||
d = Buffer.concat([d, | ||
writeAddress(transaction.payload.address), | ||
]); | ||
b = b.storeAddress(transaction.payload.address); | ||
// Complete | ||
payload = b.endCell(); | ||
hints = Buffer.concat([ | ||
hints, | ||
writeUint16(d.length), | ||
d | ||
]); | ||
} | ||
else if (transaction.payload.type === 'create-proposal') { | ||
hints = Buffer.concat([ | ||
writeUint8(1), | ||
writeUint32(0x05) | ||
]); | ||
// Build cells and hints | ||
let b = (0, ton_1.beginCell)() | ||
.storeUint(0xc1387443, 32); | ||
let d = Buffer.alloc(0); | ||
// Query ID | ||
if (transaction.payload.queryId !== null) { | ||
d = Buffer.concat([d, writeUint8(1), writeUint64(transaction.payload.queryId)]); | ||
b = b.storeUint(transaction.payload.queryId, 64); | ||
} | ||
else { | ||
d = Buffer.concat([d, writeUint8(0)]); | ||
} | ||
// Proposal ID | ||
if (transaction.payload.id !== null) { | ||
d = Buffer.concat([d, writeUint8(1), writeUint32(transaction.payload.id)]); | ||
b = b.storeUint(transaction.payload.id, 32); | ||
} | ||
else { | ||
d = Buffer.concat([d, writeUint8(0)]); | ||
} | ||
// Proposal | ||
d = Buffer.concat([d, | ||
writeCellRef(transaction.payload.proposal) | ||
]); | ||
b = b.storeRef(transaction.payload.proposal); | ||
// Proposal | ||
d = Buffer.concat([d, | ||
writeCellRef(transaction.payload.metadata) | ||
]); | ||
b = b.storeRef(transaction.payload.metadata); | ||
// Complete | ||
payload = b.endCell(); | ||
hints = Buffer.concat([ | ||
hints, | ||
writeUint16(d.length), | ||
d | ||
]); | ||
} | ||
else if (transaction.payload.type === 'vote-proposal') { | ||
hints = Buffer.concat([ | ||
writeUint8(1), | ||
writeUint32(0x06) | ||
]); | ||
// Build cells and hints | ||
let b = (0, ton_1.beginCell)() | ||
.storeUint(0xb5a563c1, 32); | ||
let d = Buffer.alloc(0); | ||
// Query ID | ||
if (transaction.payload.queryId !== null) { | ||
d = Buffer.concat([d, writeUint8(1), writeUint64(transaction.payload.queryId)]); | ||
b = b.storeUint(transaction.payload.queryId, 64); | ||
} | ||
else { | ||
d = Buffer.concat([d, writeUint8(0)]); | ||
} | ||
// ID | ||
d = Buffer.concat([d, writeUint32(transaction.payload.id)]); | ||
b = b.storeUint(transaction.payload.id, 32); | ||
// Vote | ||
let voteKey = 0x00; | ||
if (transaction.payload.vote === 'yes') { | ||
voteKey = 0x01; | ||
} | ||
else if (transaction.payload.vote === 'abstain') { | ||
voteKey = 0x02; | ||
} | ||
// Store | ||
d = Buffer.concat([d, writeUint8(voteKey)]); | ||
b = b.storeUint(voteKey, 2); | ||
// Complete | ||
payload = b.endCell(); | ||
hints = Buffer.concat([ | ||
hints, | ||
writeUint16(d.length), | ||
d | ||
]); | ||
} | ||
else if (transaction.payload.type === 'execute-proposal') { | ||
hints = Buffer.concat([ | ||
writeUint8(1), | ||
writeUint32(0x07) | ||
]); | ||
// Build cells and hints | ||
let b = (0, ton_1.beginCell)() | ||
.storeUint(0x93ff9cd3, 32); | ||
let d = Buffer.alloc(0); | ||
// Query ID | ||
if (transaction.payload.queryId !== null) { | ||
d = Buffer.concat([d, writeUint8(1), writeUint64(transaction.payload.queryId)]); | ||
b = b.storeUint(transaction.payload.queryId, 64); | ||
} | ||
else { | ||
d = Buffer.concat([d, writeUint8(0)]); | ||
} | ||
// ID | ||
d = Buffer.concat([d, writeUint32(transaction.payload.id)]); | ||
b = b.storeUint(transaction.payload.id, 32); | ||
// Complete | ||
payload = b.endCell(); | ||
hints = Buffer.concat([ | ||
hints, | ||
writeUint16(d.length), | ||
d | ||
]); | ||
} | ||
else if (transaction.payload.type === 'abort-proposal') { | ||
hints = Buffer.concat([ | ||
writeUint8(1), | ||
writeUint32(0x08) | ||
]); | ||
// Build cells and hints | ||
let b = (0, ton_1.beginCell)() | ||
.storeUint(0x5ce656a5, 32); | ||
let d = Buffer.alloc(0); | ||
// Query ID | ||
if (transaction.payload.queryId !== null) { | ||
d = Buffer.concat([d, writeUint8(1), writeUint64(transaction.payload.queryId)]); | ||
b = b.storeUint(transaction.payload.queryId, 64); | ||
} | ||
else { | ||
d = Buffer.concat([d, writeUint8(0)]); | ||
} | ||
// ID | ||
d = Buffer.concat([d, writeUint32(transaction.payload.id)]); | ||
b = b.storeUint(transaction.payload.id, 32); | ||
// Complete | ||
payload = b.endCell(); | ||
hints = Buffer.concat([ | ||
hints, | ||
writeUint16(d.length), | ||
d | ||
]); | ||
} | ||
} | ||
@@ -420,1 +587,13 @@ // | ||
} | ||
function writeAddress(address) { | ||
return Buffer.concat([ | ||
writeUint8(address.workChain === -1 ? 0xff : address.workChain), | ||
address.hash | ||
]); | ||
} | ||
function writeCellRef(ref) { | ||
return Buffer.concat([ | ||
writeUint16(ref.getMaxDepth()), | ||
ref.hash() | ||
]); | ||
} |
{ | ||
"name": "ton-ledger", | ||
"version": "2.0.0", | ||
"version": "2.1.0", | ||
"repository": "https://github.com/ton-foundation/ton-ledger-ts.git", | ||
@@ -5,0 +5,0 @@ "author": "Steve Korshakov <steve@korshakov.com>", |
24747
43.75%682
42.08%