Skip to content

Commit

Permalink
show transaction history
Browse files Browse the repository at this point in the history
  • Loading branch information
cosmasken committed Feb 13, 2024
1 parent b39da31 commit 7b9a631
Show file tree
Hide file tree
Showing 102 changed files with 1,245 additions and 189 deletions.
1 change: 1 addition & 0 deletions .dfx/local/canisters/backend/backend.did
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ type Backend =
get_account_identifier: (GetAccountIdentifierArgs) ->
(GetAccountIdentifierResult) query;
get_transaction: (GetTransactionArgs) -> (GetTransactionResult) query;
get_transactions: () -> (vec Transaction) query;
save_transaction: (CreateTransactionArgs) -> (CreateTransactionResult);
/// * Set the courier API key. Only the owner can set the courier API key.
setCourierApiKey: (text) -> (Response_2);
Expand Down
Binary file modified .dfx/local/canisters/backend/backend.wasm
Binary file not shown.
1 change: 1 addition & 0 deletions .dfx/local/canisters/backend/constructor.did
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ type Backend =
get_account_identifier: (GetAccountIdentifierArgs) ->
(GetAccountIdentifierResult) query;
get_transaction: (GetTransactionArgs) -> (GetTransactionResult) query;
get_transactions: () -> (vec Transaction) query;
save_transaction: (CreateTransactionArgs) -> (CreateTransactionResult);
/// * Set the courier API key. Only the owner can set the courier API key.
setCourierApiKey: (text) -> (Response_2);
Expand Down
1 change: 1 addition & 0 deletions .dfx/local/canisters/backend/service.did
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ type Backend = service {
GetAccountIdentifierResult,
) query;
get_transaction : (GetTransactionArgs) -> (GetTransactionResult) query;
get_transactions : () -> (vec Transaction) query;
save_transaction : (CreateTransactionArgs) -> (CreateTransactionResult);
setCourierApiKey : (text) -> (Response_2);
transferFromCanistertoSubAccount : () -> (Result);
Expand Down
1 change: 1 addition & 0 deletions .dfx/local/canisters/backend/service.did.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export interface Backend {
GetAccountIdentifierResult
>,
'get_transaction' : ActorMethod<[GetTransactionArgs], GetTransactionResult>,
'get_transactions' : ActorMethod<[], Array<Transaction>>,
'save_transaction' : ActorMethod<
[CreateTransactionArgs],
CreateTransactionResult
Expand Down
15 changes: 8 additions & 7 deletions .dfx/local/canisters/backend/service.did.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,13 @@ export const idlFactory = ({ IDL }) => {
'ok' : GetTransactionSuccess,
'err' : GetTransactionErr,
});
const Transaction = IDL.Record({
'id' : IDL.Nat,
'creator' : IDL.Principal,
'destination' : IDL.Principal,
'amount' : IDL.Nat,
'successful' : IDL.Bool,
});
const CreateTransactionArgs = IDL.Record({
'creator' : IDL.Principal,
'destination' : IDL.Principal,
Expand Down Expand Up @@ -97,13 +104,6 @@ export const idlFactory = ({ IDL }) => {
'error_text' : IDL.Opt(IDL.Text),
});
const Result = IDL.Variant({ 'ok' : IDL.Text, 'err' : IDL.Text });
const Transaction = IDL.Record({
'id' : IDL.Nat,
'creator' : IDL.Principal,
'destination' : IDL.Principal,
'amount' : IDL.Nat,
'successful' : IDL.Bool,
});
const Response_1 = IDL.Record({
'status' : IDL.Nat16,
'data' : IDL.Opt(Transaction),
Expand Down Expand Up @@ -141,6 +141,7 @@ export const idlFactory = ({ IDL }) => {
[GetTransactionResult],
['query'],
),
'get_transactions' : IDL.Func([], [IDL.Vec(Transaction)], ['query']),
'save_transaction' : IDL.Func(
[CreateTransactionArgs],
[CreateTransactionResult],
Expand Down
88 changes: 88 additions & 0 deletions .dfx/local/canisters/idl/br5f7-7uaaa-aaaaa-qaaca-cai.did
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
type TxId = nat;

type Account = record { owner : principal; subaccount : opt blob };

type SubAccount = blob;

type Transaction = record {
kind : text;
mint : opt record {
amount : nat;
to : Account;
memo : opt blob;
created_at_time : opt nat64;
};
burn : opt record {
amount : nat;
from : Account;
spender : opt Account;
memo : opt blob;
created_at_time : opt nat64;
};
transfer : opt record {
amount : nat;
from : Account;
to : Account;
spender : opt Account;
memo : opt blob;
created_at_time : opt nat64;
fee : opt nat;
};
approve : opt record {
amount : nat;
from : Account;
spender : opt Account;
expected_allowance : opt nat;
expires_at : opt nat64;
memo : opt blob;
created_at_time : opt nat64;
fee : opt nat;
};
timestamp : nat64;
};

type GetAccountTransactionsArgs = record {
account : Account;
// The txid of the last transaction seen by the client.
// If None then the results will start from the most recent
// txid.
start : opt TxId;
// Maximum number of transactions to fetch.
max_results : nat;
};

type TransactionWithId = record {
id : TxId;
transaction : Transaction;
};

type GetTransactions = record {
transactions : vec TransactionWithId;
// The txid of the oldest transaction the account has
oldest_tx_id : opt TxId;
};

type GetTransactionsErr = record {
message : text;
};

type GetTransactionsResult = variant {
Ok : GetTransactions;
Err : GetTransactionsErr;
};

type ListSubaccountsArgs = record {
owner: principal;
start: opt SubAccount;
};

// The initialization parameters of the Index canister.
type InitArgs = record {
ledger_id : principal;
};

service : (InitArgs) -> {
get_account_transactions : (GetAccountTransactionsArgs) -> (GetTransactionsResult);
ledger_id : () -> (principal) query;
list_subaccounts : (ListSubaccountsArgs) -> (vec SubAccount) query;
}
Loading

0 comments on commit 7b9a631

Please sign in to comment.