on master help sign in
Clean up lib/txn code.
483c410Jared Tobin
src/lib/txn.js+1−73
@@ -12,7 +12,6 @@ import {
12 addHexPrefix
12 addHexPrefix
13 } from '../lib/wallet'
13 } from '../lib/wallet'
14
14
15−
16const TXN_PURPOSE = {
15const TXN_PURPOSE = {
17 SET_MANAGEMENT_PROXY: Symbol('SET_MANAGEMENT_PROXY'),
16 SET_MANAGEMENT_PROXY: Symbol('SET_MANAGEMENT_PROXY'),
18 SET_TRANSFER_PROXY: Symbol('SET_TRANSFER_PROXY'),
17 SET_TRANSFER_PROXY: Symbol('SET_TRANSFER_PROXY'),
@@ -43,35 +42,6 @@ const renderTxnPurpose = (purpose) =>
43 ? 'cancel this transfer'
42 ? 'cancel this transfer'
44 : 'perform this transaction'
43 : 'perform this transaction'
45
44
46−
47−
48−
49−
50−// const createUnsignedTxn = config => {
51−// const {
52−// contracts,
53−// galaxyName,
54−// add,
55−// setTxn
56−// } = config
57−//
58−// const ctrcs = contracts.matchWith({
59−// Just: (cs) => cs.value,
60−// Nothing: () => {
61−// throw BRIDGE_ERROR.MISSING_CONTRACTS
62−// }
63−// })
64−//
65−// const galaxy = parseInt(ob.patp2dec(galaxyName), 10)
66−//
67−// const txn = isValidGalaxy(galaxyName) && isValidAddress(galaxyOwner)
68−// ? Maybe.Just(azimuth.ecliptic.createGalaxy(ctrcs, galaxy, galaxyOwner))
69−// : Maybe.Nothing()
70−//
71−// setTxn(txn)
72−// }
73−
74−
75const signTransaction = async config => {
45const signTransaction = async config => {
76
46
77 let {
47 let {
@@ -93,9 +63,7 @@ const signTransaction = async config => {
93
63
94 const wal = wallet.matchWith({
64 const wal = wallet.matchWith({
95 Just: (w) => w.value,
65 Just: (w) => w.value,
96− Nothing: () => {
97− throw BRIDGE_ERROR.MISSING_WALLET
66+ Nothing: () => { throw BRIDGE_ERROR.MISSING_WALLET }
98− }
99 })
67 })
100
68
101 const sec = wal.privateKey
69 const sec = wal.privateKey
@@ -121,8 +89,6 @@ const signTransaction = async config => {
121 setStx(Maybe.Just(stx))
89 setStx(Maybe.Just(stx))
122}
90}
123
91
124−
125−
126const sendSignedTransaction = (web3, stx) => {
92const sendSignedTransaction = (web3, stx) => {
127 const txn = stx.matchWith({
93 const txn = stx.matchWith({
128 Just: (tx) => tx.value,
94 Just: (tx) => tx.value,
@@ -170,28 +136,6 @@ const toHex = dummy.utils.toHex
170const toWei = dummy.utils.toWei
136const toWei = dummy.utils.toWei
171const fromWei = dummy.utils.fromWei
137const fromWei = dummy.utils.fromWei
172
138
173−
174−// const confirmShipAvailability = (point, contracts) => {
175−//
176−// if (canDecodePatp(point) === true) {
177−//
178−// const pointDec = ob.patp2dec(point)
179−//
180−// contracts.matchWith({
181−// Nothing: () => {
182−// throw BRIDGE_ERROR.MISSING_CONTRACTS
183−// },
184−// Just: async (contracts) => {
185−// const owner = await azimuth.azimuth.getOwner(contracts.value, point)
186−// if (eqAddr(owner, ETH_ZERO_ADDR)) return true
187−// return false
188−// }
189−// })
190−// }
191−// return false
192−// }
193−
194−
195const canDecodePatp = p => {
139const canDecodePatp = p => {
196 try {
140 try {
197 ob.patp2dec(p)
141 ob.patp2dec(p)
@@ -201,21 +145,6 @@ const canDecodePatp = p => {
201 }
145 }
202}
146}
203
147
204−
205−
206−
207−
208−// const bridgeAPI = {
209−// shipAvailability: {
210−// planet: planet => {},
211−// star: star => {},
212−// galaxy: galaxy => {},
213−// },
214−// // dummyWeb3: {
215−// //
216−// // }
217−// }
218−
219export {
148export {
220 signTransaction,
149 signTransaction,
221 sendSignedTransaction,
150 sendSignedTransaction,
@@ -228,5 +157,4 @@ export {
228 toWei,
157 toWei,
229 fromWei,
158 fromWei,
230 canDecodePatp,
159 canDecodePatp,
231− // confirmShipAvailability,
232}
160}