Skip to content
Merged
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
1 change: 1 addition & 0 deletions light-sdk-ts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"test-relayer": "ts-mocha --resolveJsonModule ./tsconfig.json -t 100000000 tests/relayer.test.ts --exit",
"test-createOutUtxos": "ts-mocha --resolveJsonModule ./tsconfig.json -t 100000000 tests/createOutUtxos.test.ts --exit",
"test-provider": "ts-mocha --resolveJsonModule ./tsconfig.json -t 100000000 tests/provider.test.ts --exit",
"test-selectInUtxos": "ts-mocha --resolveJsonModule ./tsconfig.json -t 100000000 tests/selectInUtxos.test.ts --exit",
"build": "yarn tsc",
"format": "prettier --write \"src/**/*.{ts,js}\"",
"lint:fix": "prettier */*.js \"*/**/*{.js,.ts}\" -w",
Expand Down
9 changes: 9 additions & 0 deletions light-sdk-ts/src/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ export enum UtxoErrorCode {
ASSET_NOT_FOUND = "ASSET_NOT_FOUND",
}

export enum SelectInUtxosErrorCode {
INVALID_NUMER_OF_MINTS = "INVALID_NUMER_OF_MINTS",
FAILED_TO_SELECT_SOL_UTXO = "FAILED_TO_SELECT_SOL_UTXO",
FAILED_TO_FIND_UTXO_COMBINATION = "FAILED_TO_FIND_UTXO_COMBINATION",
}

export enum RelayerErrorCode {
RELAYER_FEE_UNDEFINED = "RELAYER_FEE_UNDEFINED",
RELAYER_PUBKEY_UNDEFINED = "RELAYER_PUBKEY_UNDEFINED",
Expand All @@ -29,6 +35,7 @@ export enum CreateUtxoErrorCode {
INVALID_OUTPUT_UTXO_LENGTH = "INVALID_OUTPUT_UTXO_LENGTH",
RELAYER_FEE_DEFINED = "RELAYER_FEE_DEFINED",
PUBLIC_SOL_AMOUNT_UNDEFINED = "PUBLIC_SOL_AMOUNT_UNDEFINED",
PUBLIC_SPL_AMOUNT_UNDEFINED = "PUBLIC_SPL_AMOUNT_UNDEFINED",
}
export enum AccountErrorCode {
INVALID_SEED_SIZE = "INVALID_SEED_SIZE",
Expand Down Expand Up @@ -156,3 +163,5 @@ export class RelayerError extends MetaError {}
export class CreateUtxoError extends MetaError {}

export class ProviderError extends MetaError {}

export class SelectInUtxosError extends MetaError {}
3 changes: 2 additions & 1 deletion light-sdk-ts/src/transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,8 @@ export class TransactionParameters implements transactionParameters {
this.accounts.recipientFee =
MerkleTreeConfig.getSolPoolPda(merkleTreeProgramId).pda;
if (!this.accounts.sender) {
this.accounts.sender = SystemProgram.programId;
// assigning a placeholder account
this.accounts.sender = AUTHORITY;
if (!this.publicAmountSpl?.eq(new BN(0))) {
throw new TransactioParametersError(
TransactionErrorCode.SPL_SENDER_UNDEFINED,
Expand Down
7 changes: 5 additions & 2 deletions light-sdk-ts/src/wallet/createOutUtxos.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export type Recipient = {
mint: PublicKey;
};
// mint: PublicKey, expectedAmount: BN,
const getUtxoArrayAmount = (mint: PublicKey, inUtxos: Utxo[]) => {
export const getUtxoArrayAmount = (mint: PublicKey, inUtxos: Utxo[]) => {
let inAmount = new BN(0);
inUtxos.forEach((inUtxo) => {
inUtxo.assets.forEach((asset, i) => {
Expand All @@ -31,7 +31,10 @@ const getUtxoArrayAmount = (mint: PublicKey, inUtxos: Utxo[]) => {
return inAmount;
};

const getRecipientsAmount = (mint: PublicKey, recipients: Recipient[]) => {
export const getRecipientsAmount = (
mint: PublicKey,
recipients: Recipient[],
) => {
if (mint.toBase58() === SystemProgram.programId.toBase58()) {
return recipients.reduce(
(sum, recipient) => sum.add(recipient.solAmount),
Expand Down
Loading