Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions bun.lock

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

10 changes: 2 additions & 8 deletions packages/contracts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,9 @@
"author": "swapkit-oss",
"description": "SwapKit - Contracts",
"exports": {
".": {
"import": "./dist/index.js",
"require": "./dist/index.cjs",
"types": "./dist/types/index.d.ts"
}
".": { "import": "./dist/index.js", "require": "./dist/index.cjs", "types": "./dist/types/index.d.ts" }
},
"files": [
"dist/"
],
"files": ["dist/"],
"homepage": "https://github.com/swapkit/SwapKit",
"license": "Apache-2.0",
"name": "@swapkit/contracts",
Expand Down
64 changes: 62 additions & 2 deletions packages/helpers/src/api/swapkitApi/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,20 @@ export const EVMTransactionSchema = object({

export type EVMTransaction = z.infer<typeof EVMTransactionSchema>;

export const NEARTransactionSchema = z.object({
details: z.object({
blockHash: z.string().describe("Hash of the block"),
nonce: z.number().describe("Nonce of the transaction"),
signerId: z.string().describe("ID of the signer"),
}),
gas: z.string().describe("Gas limit for the transaction"),
gasPrice: z.string().describe("Gas price for the transaction"),
publicKey: z.string().describe("Public key of the signer"),
serialized: z.string().describe("Serialized transaction"),
});

export type NEARTransaction = z.infer<typeof NEARTransactionSchema>;

export const EVMTransactionDetailsParamsSchema = array(
union([
string(),
Expand All @@ -412,6 +426,21 @@ export const EVMTransactionDetailsParamsSchema = array(
]),
);

export const TronTransactionSchema = z.object({
raw_data: z.object({
contract: z.any(),
expiration: z.number(),
ref_block_bytes: z.string(),
ref_block_hash: z.string(),
timestamp: z.number(),
}),
raw_data_hex: z.string(),
txID: z.string(),
visible: z.boolean(),
});

export type TronTransaction = z.infer<typeof TronTransactionSchema>;

export type EVMTransactionDetailsParams = z.infer<typeof EVMTransactionDetailsParamsSchema>;

export const EVMTransactionDetailsSchema = object({
Expand All @@ -425,7 +454,36 @@ export const EVMTransactionDetailsSchema = object({

export type EVMTransactionDetails = z.infer<typeof EVMTransactionDetailsSchema>;

const EncodeObjectSchema = object({ typeUrl: string(), value: unknown() });
const ThorchainDepositMsgSchema = object({
typeUrl: string("/types.MsgDeposit"),
value: object({
coins: array(
object({
amount: string(),
asset: object({ chain: string(), symbol: string(), synth: boolean(), ticker: string() }),
}),
),
memo: string(),
signer: string(),
}),
});

export type ThorchainDepositMsg = z.infer<typeof ThorchainDepositMsgSchema>;

const CosmosSendMsgSchema = object({
typeUrl: string("/types.MsgSend"),
value: object({
amount: array(object({ amount: string(), denom: string() })),
fromAddress: string(),
toAddress: string(),
}),
});

export type CosmosSendMsg = z.infer<typeof CosmosSendMsgSchema>;

const EncodeObjectSchema = object({ typeUrl: string(), value: CosmosSendMsgSchema.or(ThorchainDepositMsgSchema) });

export type APICosmosEncodedObject = z.infer<typeof EncodeObjectSchema>;

const FeeSchema = object({ amount: array(object({ amount: string(), denom: string() })), gas: string() });

Expand Down Expand Up @@ -527,7 +585,9 @@ const QuoteResponseRouteItem = object({
sourceAddress: string().describe("Source address"),
targetAddress: optional(string().describe("Target address")),
totalSlippageBps: number().describe("Total slippage in bps"),
tx: optional(union([EVMTransactionSchema, CosmosTransactionSchema, string()])),
tx: optional(
union([EVMTransactionSchema, CosmosTransactionSchema, NEARTransactionSchema, TronTransactionSchema, string()]),
),
txType: optional(z.enum(RouteQuoteTxType)),
warnings: RouteQuoteWarningSchema,
});
Expand Down
Loading