Skip to content

Commit

Permalink
feat[doge_customs]: auto find un-generate ticket txids from recently txs
Browse files Browse the repository at this point in the history
  • Loading branch information
hsxyl committed Jan 23, 2025
1 parent e051e02 commit d85d4cc
Show file tree
Hide file tree
Showing 19 changed files with 1,514 additions and 600 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

46 changes: 37 additions & 9 deletions assets/doge_customs/service.did.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ export interface EcdsaPublicKeyResponse {
'chain_code' : Uint8Array | number[],
}
export interface GenerateTicketArgs {
'token_id' : string,
'target_chain_id' : string,
'receiver' : string,
}
export interface GenerateTicketWithTxidArgs {
'token_id' : string,
'txid' : string,
'target_chain_id' : string,
Expand All @@ -69,18 +74,26 @@ export interface LockTicketRequest {
'amount' : string,
'receiver' : string,
}
export interface MultiRpcConfig {
'rpc_list' : Array<RpcConfig>,
'minimum_response_count' : number,
}
export type ReleaseTokenStatus = { 'Signing' : null } |
{ 'Confirmed' : string } |
{ 'Sending' : string } |
{ 'Unknown' : null } |
{ 'Submitted' : string } |
{ 'Pending' : null };
export type Result = { 'Ok' : null } |
export type Result = { 'Ok' : Array<string> } |
{ 'Err' : CustomsError };
export type Result_1 = { 'Ok' : string } |
export type Result_1 = { 'Ok' : null } |
{ 'Err' : CustomsError };
export type Result_2 = { 'Ok' : string } |
{ 'Err' : CustomsError };
export type Result_3 = { 'Ok' : string } |
{ 'Err' : string };
export type Result_4 = { 'Ok' : bigint } |
{ 'Err' : CustomsError };
export interface RpcConfig { 'url' : string, 'api_key' : [] | [string] }
export interface SendTicketResult {
'txid' : Uint8Array | number[],
Expand All @@ -103,12 +116,14 @@ export interface StateProfile {
'tokens' : Array<[string, Token]>,
'admins' : Array<Principal>,
'target_chain_factor' : Array<[string, bigint]>,
'multi_rpc_config' : MultiRpcConfig,
'counterparties' : Array<[string, Chain]>,
'min_deposit_amount' : bigint,
'next_ticket_seq' : bigint,
'chain_state' : ChainState,
'min_confirmations' : number,
'default_rpc_config' : RpcConfig,
'tatum_rpc_config' : RpcConfig,
'fee_payment_utxo' : Array<Utxo>,
'flight_unlock_ticket_map' : Array<[bigint, SendTicketResult]>,
'fee_token_factor' : [] | [bigint],
}
Expand All @@ -132,24 +147,37 @@ export interface Utxo {
'vout' : number,
}
export interface _SERVICE {
'finalized_unlock_tickets' : ActorMethod<[bigint], string>,
'generate_ticket' : ActorMethod<[GenerateTicketArgs], Result>,
'get_deposit_address' : ActorMethod<[string, string], Result_1>,
'generate_ticket_by_txid' : ActorMethod<
[GenerateTicketWithTxidArgs],
Result_1
>,
'get_deposit_address' : ActorMethod<[string, string], Result_2>,
'get_fee_payment_address' : ActorMethod<[], Result_2>,
'get_finalized_lock_ticket_txids' : ActorMethod<[], Array<string>>,
'get_finalized_unlock_ticket_results' : ActorMethod<
[],
Array<SendTicketResult>
>,
'get_platform_fee' : ActorMethod<[string], [[] | [bigint], [] | [string]]>,
'get_token_list' : ActorMethod<[], Array<TokenResp>>,
'init_ecdsa_public_key' : ActorMethod<[], Result>,
'init_ecdsa_public_key' : ActorMethod<[], Result_1>,
'pending_unlock_tickets' : ActorMethod<[bigint], string>,
'query_finalized_lock_tickets' : ActorMethod<
[string],
[] | [LockTicketRequest]
>,
'query_state' : ActorMethod<[], StateProfile>,
'release_token_status' : ActorMethod<[string], ReleaseTokenStatus>,
'resend_unlock_ticket' : ActorMethod<[bigint, [] | [bigint]], Result_2>,
'resend_unlock_ticket' : ActorMethod<[bigint, [] | [bigint]], Result_3>,
'save_utxo_for_payment_address' : ActorMethod<[string], Result_4>,
'set_default_doge_rpc_config' : ActorMethod<
[string, [] | [string]],
undefined
>,
'set_fee_collector' : ActorMethod<[string], undefined>,
'set_min_deposit_amount' : ActorMethod<[bigint], undefined>,
'set_rpc_config' : ActorMethod<[string, [] | [string]], undefined>,
'test_http' : ActorMethod<[string, string, [] | [string]], Result_1>,
'set_tatum_api_config' : ActorMethod<[string, [] | [string]], undefined>,
'tmp_fix' : ActorMethod<[], undefined>,
}
export declare const idlFactory: IDL.InterfaceFactory;
Expand Down
80 changes: 56 additions & 24 deletions assets/doge_customs/service.did.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ export const idlFactory = ({ IDL }) => {
});
const GenerateTicketArgs = IDL.Record({
'token_id' : IDL.Text,
'txid' : IDL.Text,
'target_chain_id' : IDL.Text,
'receiver' : IDL.Text,
});
Expand Down Expand Up @@ -42,8 +41,23 @@ export const idlFactory = ({ IDL }) => {
'UnsupportedToken' : IDL.Text,
'CustomError' : IDL.Text,
});
const Result = IDL.Variant({ 'Ok' : IDL.Null, 'Err' : CustomsError });
const Result_1 = IDL.Variant({ 'Ok' : IDL.Text, 'Err' : CustomsError });
const Result = IDL.Variant({
'Ok' : IDL.Vec(IDL.Text),
'Err' : CustomsError,
});
const GenerateTicketWithTxidArgs = IDL.Record({
'token_id' : IDL.Text,
'txid' : IDL.Text,
'target_chain_id' : IDL.Text,
'receiver' : IDL.Text,
});
const Result_1 = IDL.Variant({ 'Ok' : IDL.Null, 'Err' : CustomsError });
const Result_2 = IDL.Variant({ 'Ok' : IDL.Text, 'Err' : CustomsError });
const SendTicketResult = IDL.Record({
'txid' : IDL.Vec(IDL.Nat8),
'success' : IDL.Bool,
'time_at' : IDL.Nat64,
});
const TokenResp = IDL.Record({
'decimals' : IDL.Nat8,
'token_id' : IDL.Text,
Expand Down Expand Up @@ -76,6 +90,14 @@ export const idlFactory = ({ IDL }) => {
'name' : IDL.Text,
'symbol' : IDL.Text,
});
const RpcConfig = IDL.Record({
'url' : IDL.Text,
'api_key' : IDL.Opt(IDL.Text),
});
const MultiRpcConfig = IDL.Record({
'rpc_list' : IDL.Vec(RpcConfig),
'minimum_response_count' : IDL.Nat32,
});
const ChainState = IDL.Variant({
'Active' : IDL.Null,
'Deactive' : IDL.Null,
Expand All @@ -93,15 +115,6 @@ export const idlFactory = ({ IDL }) => {
'chain_type' : ChainType,
'contract_address' : IDL.Opt(IDL.Text),
});
const RpcConfig = IDL.Record({
'url' : IDL.Text,
'api_key' : IDL.Opt(IDL.Text),
});
const SendTicketResult = IDL.Record({
'txid' : IDL.Vec(IDL.Nat8),
'success' : IDL.Bool,
'time_at' : IDL.Nat64,
});
const StateProfile = IDL.Record({
'next_consume_ticket_seq' : IDL.Nat64,
'fee_token' : IDL.Text,
Expand All @@ -120,12 +133,14 @@ export const idlFactory = ({ IDL }) => {
'tokens' : IDL.Vec(IDL.Tuple(IDL.Text, Token)),
'admins' : IDL.Vec(IDL.Principal),
'target_chain_factor' : IDL.Vec(IDL.Tuple(IDL.Text, IDL.Nat)),
'multi_rpc_config' : MultiRpcConfig,
'counterparties' : IDL.Vec(IDL.Tuple(IDL.Text, Chain)),
'min_deposit_amount' : IDL.Nat64,
'next_ticket_seq' : IDL.Nat64,
'chain_state' : ChainState,
'min_confirmations' : IDL.Nat32,
'default_rpc_config' : RpcConfig,
'tatum_rpc_config' : RpcConfig,
'fee_payment_utxo' : IDL.Vec(Utxo),
'flight_unlock_ticket_map' : IDL.Vec(
IDL.Tuple(IDL.Nat64, SendTicketResult)
),
Expand All @@ -139,13 +154,29 @@ export const idlFactory = ({ IDL }) => {
'Submitted' : IDL.Text,
'Pending' : IDL.Null,
});
const Result_2 = IDL.Variant({ 'Ok' : IDL.Text, 'Err' : IDL.Text });
const Result_3 = IDL.Variant({ 'Ok' : IDL.Text, 'Err' : IDL.Text });
const Result_4 = IDL.Variant({ 'Ok' : IDL.Nat64, 'Err' : CustomsError });
return IDL.Service({
'finalized_unlock_tickets' : IDL.Func([IDL.Nat64], [IDL.Text], ['query']),
'generate_ticket' : IDL.Func([GenerateTicketArgs], [Result], []),
'generate_ticket_by_txid' : IDL.Func(
[GenerateTicketWithTxidArgs],
[Result_1],
[],
),
'get_deposit_address' : IDL.Func(
[IDL.Text, IDL.Text],
[Result_1],
[Result_2],
['query'],
),
'get_fee_payment_address' : IDL.Func([], [Result_2], ['query']),
'get_finalized_lock_ticket_txids' : IDL.Func(
[],
[IDL.Vec(IDL.Text)],
['query'],
),
'get_finalized_unlock_ticket_results' : IDL.Func(
[],
[IDL.Vec(SendTicketResult)],
['query'],
),
'get_platform_fee' : IDL.Func(
Expand All @@ -154,7 +185,7 @@ export const idlFactory = ({ IDL }) => {
['query'],
),
'get_token_list' : IDL.Func([], [IDL.Vec(TokenResp)], ['query']),
'init_ecdsa_public_key' : IDL.Func([], [Result], []),
'init_ecdsa_public_key' : IDL.Func([], [Result_1], []),
'pending_unlock_tickets' : IDL.Func([IDL.Nat64], [IDL.Text], ['query']),
'query_finalized_lock_tickets' : IDL.Func(
[IDL.Text],
Expand All @@ -169,17 +200,18 @@ export const idlFactory = ({ IDL }) => {
),
'resend_unlock_ticket' : IDL.Func(
[IDL.Nat64, IDL.Opt(IDL.Nat64)],
[Result_2],
[Result_3],
[],
),
'set_fee_collector' : IDL.Func([IDL.Text], [], []),
'set_min_deposit_amount' : IDL.Func([IDL.Nat64], [], []),
'set_rpc_config' : IDL.Func([IDL.Text, IDL.Opt(IDL.Text)], [], []),
'test_http' : IDL.Func(
[IDL.Text, IDL.Text, IDL.Opt(IDL.Text)],
[Result_1],
'save_utxo_for_payment_address' : IDL.Func([IDL.Text], [Result_4], []),
'set_default_doge_rpc_config' : IDL.Func(
[IDL.Text, IDL.Opt(IDL.Text)],
[],
[],
),
'set_fee_collector' : IDL.Func([IDL.Text], [], []),
'set_min_deposit_amount' : IDL.Func([IDL.Nat64], [], []),
'set_tatum_api_config' : IDL.Func([IDL.Text, IDL.Opt(IDL.Text)], [], []),
'tmp_fix' : IDL.Func([], [], []),
});
};
Expand Down
3 changes: 2 additions & 1 deletion customs/doge/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,5 @@ k256 = { git = "https://github.com/altkdf/elliptic-curves", branch = "schnorr_ca
# rust_decimal_macros = {workspace = true}
rust_decimal = "1.36"
rust_decimal_macros = "1.36"
log = "0.4.22"
log = "0.4.22"
bincode = "1.3.3"
37 changes: 27 additions & 10 deletions customs/doge/doge_customs.did
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ type Destination = record {
};
type EcdsaPublicKeyResponse = record { public_key : blob; chain_code : blob };
type GenerateTicketArgs = record {
token_id : text;
target_chain_id : text;
receiver : text;
};
type GenerateTicketWithTxidArgs = record {
token_id : text;
txid : text;
target_chain_id : text;
Expand All @@ -62,6 +67,10 @@ type LockTicketRequest = record {
amount : text;
receiver : text;
};
type MultiRpcConfig = record {
rpc_list : vec RpcConfig;
minimum_response_count : nat32;
};
type ReleaseTokenStatus = variant {
Signing;
Confirmed : text;
Expand All @@ -70,9 +79,11 @@ type ReleaseTokenStatus = variant {
Submitted : text;
Pending;
};
type Result = variant { Ok; Err : CustomsError };
type Result_1 = variant { Ok : text; Err : CustomsError };
type Result_2 = variant { Ok : text; Err : text };
type Result = variant { Ok : vec text; Err : CustomsError };
type Result_1 = variant { Ok; Err : CustomsError };
type Result_2 = variant { Ok : text; Err : CustomsError };
type Result_3 = variant { Ok : text; Err : text };
type Result_4 = variant { Ok : nat64; Err : CustomsError };
type RpcConfig = record { url : text; api_key : opt text };
type SendTicketResult = record { txid : blob; success : bool; time_at : nat64 };
type StateProfile = record {
Expand All @@ -91,12 +102,14 @@ type StateProfile = record {
tokens : vec record { text; Token };
admins : vec principal;
target_chain_factor : vec record { text; nat };
multi_rpc_config : MultiRpcConfig;
counterparties : vec record { text; Chain };
min_deposit_amount : nat64;
next_ticket_seq : nat64;
chain_state : ChainState;
min_confirmations : nat32;
default_rpc_config : RpcConfig;
tatum_rpc_config : RpcConfig;
fee_payment_utxo : vec Utxo;
flight_unlock_ticket_map : vec record { nat64; SendTicketResult };
fee_token_factor : opt nat;
};
Expand All @@ -116,20 +129,24 @@ type TokenResp = record {
};
type Utxo = record { value : nat64; txid : blob; vout : nat32 };
service : (InitArgs) -> {
finalized_unlock_tickets : (nat64) -> (text) query;
generate_ticket : (GenerateTicketArgs) -> (Result);
get_deposit_address : (text, text) -> (Result_1) query;
generate_ticket_by_txid : (GenerateTicketWithTxidArgs) -> (Result_1);
get_deposit_address : (text, text) -> (Result_2) query;
get_fee_payment_address : () -> (Result_2) query;
get_finalized_lock_ticket_txids : () -> (vec text) query;
get_finalized_unlock_ticket_results : () -> (vec SendTicketResult) query;
get_platform_fee : (text) -> (opt nat, opt text) query;
get_token_list : () -> (vec TokenResp) query;
init_ecdsa_public_key : () -> (Result);
init_ecdsa_public_key : () -> (Result_1);
pending_unlock_tickets : (nat64) -> (text) query;
query_finalized_lock_tickets : (text) -> (opt LockTicketRequest) query;
query_state : () -> (StateProfile) query;
release_token_status : (text) -> (ReleaseTokenStatus) query;
resend_unlock_ticket : (nat64, opt nat64) -> (Result_2);
resend_unlock_ticket : (nat64, opt nat64) -> (Result_3);
save_utxo_for_payment_address : (text) -> (Result_4);
set_default_doge_rpc_config : (text, opt text) -> ();
set_fee_collector : (text) -> ();
set_min_deposit_amount : (nat64) -> ();
set_rpc_config : (text, opt text) -> ();
test_http : (text, text, opt text) -> (Result_1);
set_tatum_api_config : (text, opt text) -> ();
tmp_fix : () -> ();
}
Loading

0 comments on commit d85d4cc

Please sign in to comment.