lib/cardano_wallet/byron.rb in cardano_wallet-0.3.12 vs lib/cardano_wallet/byron.rb in cardano_wallet-0.3.14

- old
+ new

@@ -208,9 +208,44 @@ end # Byron transactions # @see https://input-output-hk.github.io/cardano-wallet/api/edge/#operation/postByronTransactionFee class Transactions < Base + # Construct transaction + # @see https://input-output-hk.github.io/cardano-wallet/api/edge/#operation/constructByronTransaction + # @param wid [String] source wallet id + # @param payments [Array of Hashes] full payments payload with assets + # @param metadata [Hash] special metadata JSON subset format (cf: https://input-output-hk.github.io/cardano-wallet/api/edge/#operation/postTransaction) + # @param mint [Array of Hashes] mint object + # @param validity_interval [Hash] validity_interval object + def construct(wid, payments = nil, metadata = nil, mint = nil, validity_interval = nil) + payload = {} + payload[:payments] = payments if payments + payload[:metadata] = metadata if metadata + payload[:mint] = mint if mint + payload[:validity_interval] = validity_interval if validity_interval + + self.class.post("/byron-wallets/#{wid}/transactions-construct", + body: payload.to_json, + headers: { 'Content-Type' => 'application/json' }) + end + + # Sign transaction + # @see https://input-output-hk.github.io/cardano-wallet/api/edge/#operation/signByronTransaction + # @param wid [String] source wallet id + # @param passphrase [String] wallet's passphrase + # @param passphrase [String] CBOR transaction data + def sign(wid, passphrase, transaction) + payload = { + 'passphrase' => passphrase, + 'transaction' => transaction + } + + self.class.post("/byron-wallets/#{wid}/transactions-sign", + body: payload.to_json, + headers: { 'Content-Type' => 'application/json' }) + end + # Get tx by id # @see https://input-output-hk.github.io/cardano-wallet/api/edge/#operation/getByronTransaction def get(wid, tx_id) self.class.get("/byron-wallets/#{wid}/transactions/#{tx_id}") end