-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add withdrawal_fee_estimate to the js sdks (#338)
* Add withdrawal_fee_estimate to the js sdks (#7876) GitOrigin-RevId: a429b2377175ebbe29ff6dbcc6995a7d58953d1a * Create rotten-bears-peel.md --------- Co-authored-by: Jeremy Klein <[email protected]> Co-authored-by: Corey Martin <[email protected]>
- Loading branch information
1 parent
d694137
commit 4c93e7f
Showing
15 changed files
with
345 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
"@lightsparkdev/lightspark-sdk": minor | ||
"@lightsparkdev/wallet-sdk": minor | ||
--- | ||
|
||
Add withdrawal_fee_estimate to the js sdks |
Validating CODEOWNERS rules …
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
/ @lightsparkdev/js | ||
* @lightsparkdev/js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
packages/lightspark-sdk/src/graphql/WithdrawalFeeEstimate.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved | ||
|
||
import { FRAGMENT as WithdrawalFeeEstimateOutputFragment } from "../objects/WithdrawalFeeEstimateOutput.js"; | ||
|
||
export const WithdrawalFeeEstimate = ` | ||
query WithdrawalFeeEstimate( | ||
$node_id: ID! | ||
$amount_sats: Long! | ||
$withdrawal_mode: WithdrawalMode! | ||
) { | ||
withdrawal_fee_estimate(input: { | ||
node_id: $node_id, | ||
amount_sats: $amount_sats, | ||
withdrawal_mode: $withdrawal_mode | ||
}) { | ||
...WithdrawalFeeEstimateOutputFragment | ||
} | ||
} | ||
${WithdrawalFeeEstimateOutputFragment} | ||
`; |
40 changes: 40 additions & 0 deletions
40
packages/lightspark-sdk/src/objects/WithdrawalFeeEstimateInput.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved | ||
|
||
import WithdrawalMode from "./WithdrawalMode.js"; | ||
|
||
interface WithdrawalFeeEstimateInput { | ||
/** The node from which you'd like to make the withdrawal. **/ | ||
nodeId: string; | ||
|
||
/** | ||
* The amount you want to withdraw from this node in Satoshis. Use the special value -1 to | ||
* withdrawal all funds from this node. | ||
**/ | ||
amountSats: number; | ||
|
||
/** The strategy that should be used to withdraw the funds from this node. **/ | ||
withdrawalMode: WithdrawalMode; | ||
} | ||
|
||
export const WithdrawalFeeEstimateInputFromJson = ( | ||
obj: any, | ||
): WithdrawalFeeEstimateInput => { | ||
return { | ||
nodeId: obj["withdrawal_fee_estimate_input_node_id"], | ||
amountSats: obj["withdrawal_fee_estimate_input_amount_sats"], | ||
withdrawalMode: | ||
WithdrawalMode[obj["withdrawal_fee_estimate_input_withdrawal_mode"]] ?? | ||
WithdrawalMode.FUTURE_VALUE, | ||
} as WithdrawalFeeEstimateInput; | ||
}; | ||
export const WithdrawalFeeEstimateInputToJson = ( | ||
obj: WithdrawalFeeEstimateInput, | ||
): any => { | ||
return { | ||
withdrawal_fee_estimate_input_node_id: obj.nodeId, | ||
withdrawal_fee_estimate_input_amount_sats: obj.amountSats, | ||
withdrawal_fee_estimate_input_withdrawal_mode: obj.withdrawalMode, | ||
}; | ||
}; | ||
|
||
export default WithdrawalFeeEstimateInput; |
46 changes: 46 additions & 0 deletions
46
packages/lightspark-sdk/src/objects/WithdrawalFeeEstimateOutput.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved | ||
|
||
import type CurrencyAmount from "./CurrencyAmount.js"; | ||
import { | ||
CurrencyAmountFromJson, | ||
CurrencyAmountToJson, | ||
} from "./CurrencyAmount.js"; | ||
|
||
interface WithdrawalFeeEstimateOutput { | ||
/** The estimated fee for the withdrawal. **/ | ||
feeEstimate: CurrencyAmount; | ||
} | ||
|
||
export const WithdrawalFeeEstimateOutputFromJson = ( | ||
obj: any, | ||
): WithdrawalFeeEstimateOutput => { | ||
return { | ||
feeEstimate: CurrencyAmountFromJson( | ||
obj["withdrawal_fee_estimate_output_fee_estimate"], | ||
), | ||
} as WithdrawalFeeEstimateOutput; | ||
}; | ||
export const WithdrawalFeeEstimateOutputToJson = ( | ||
obj: WithdrawalFeeEstimateOutput, | ||
): any => { | ||
return { | ||
withdrawal_fee_estimate_output_fee_estimate: CurrencyAmountToJson( | ||
obj.feeEstimate, | ||
), | ||
}; | ||
}; | ||
|
||
export const FRAGMENT = ` | ||
fragment WithdrawalFeeEstimateOutputFragment on WithdrawalFeeEstimateOutput { | ||
__typename | ||
withdrawal_fee_estimate_output_fee_estimate: fee_estimate { | ||
__typename | ||
currency_amount_original_value: original_value | ||
currency_amount_original_unit: original_unit | ||
currency_amount_preferred_currency_unit: preferred_currency_unit | ||
currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded | ||
currency_amount_preferred_currency_value_approx: preferred_currency_value_approx | ||
} | ||
}`; | ||
|
||
export default WithdrawalFeeEstimateOutput; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved | ||
|
||
import { FRAGMENT as WithdrawalFeeEstimateOutputFragment } from "../objects/WithdrawalFeeEstimateOutput.js"; | ||
|
||
export const WithdrawalFeeEstimate = ` | ||
query WithdrawalFeeEstimate( | ||
$amount_sats: Long! | ||
$withdrawal_mode: WithdrawalMode! | ||
) { | ||
withdrawal_fee_estimate(input: { | ||
amount_sats: $amount_sats, | ||
withdrawal_mode: $withdrawal_mode | ||
}) { | ||
...WithdrawalFeeEstimateOutputFragment | ||
} | ||
} | ||
${WithdrawalFeeEstimateOutputFragment} | ||
`; |
35 changes: 35 additions & 0 deletions
35
packages/wallet-sdk/src/objects/WithdrawalFeeEstimateInput.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved | ||
|
||
import WithdrawalMode from "./WithdrawalMode.js"; | ||
|
||
interface WithdrawalFeeEstimateInput { | ||
/** | ||
* The amount you want to withdraw from this node in Satoshis. Use the special value -1 to | ||
* withdrawal all funds from this node. | ||
**/ | ||
amountSats: number; | ||
|
||
/** The strategy that should be used to withdraw the funds from this node. **/ | ||
withdrawalMode: WithdrawalMode; | ||
} | ||
|
||
export const WithdrawalFeeEstimateInputFromJson = ( | ||
obj: any, | ||
): WithdrawalFeeEstimateInput => { | ||
return { | ||
amountSats: obj["withdrawal_fee_estimate_input_amount_sats"], | ||
withdrawalMode: | ||
WithdrawalMode[obj["withdrawal_fee_estimate_input_withdrawal_mode"]] ?? | ||
WithdrawalMode.FUTURE_VALUE, | ||
} as WithdrawalFeeEstimateInput; | ||
}; | ||
export const WithdrawalFeeEstimateInputToJson = ( | ||
obj: WithdrawalFeeEstimateInput, | ||
): any => { | ||
return { | ||
withdrawal_fee_estimate_input_amount_sats: obj.amountSats, | ||
withdrawal_fee_estimate_input_withdrawal_mode: obj.withdrawalMode, | ||
}; | ||
}; | ||
|
||
export default WithdrawalFeeEstimateInput; |
46 changes: 46 additions & 0 deletions
46
packages/wallet-sdk/src/objects/WithdrawalFeeEstimateOutput.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved | ||
|
||
import type CurrencyAmount from "./CurrencyAmount.js"; | ||
import { | ||
CurrencyAmountFromJson, | ||
CurrencyAmountToJson, | ||
} from "./CurrencyAmount.js"; | ||
|
||
interface WithdrawalFeeEstimateOutput { | ||
/** The estimated fee for the withdrawal. **/ | ||
feeEstimate: CurrencyAmount; | ||
} | ||
|
||
export const WithdrawalFeeEstimateOutputFromJson = ( | ||
obj: any, | ||
): WithdrawalFeeEstimateOutput => { | ||
return { | ||
feeEstimate: CurrencyAmountFromJson( | ||
obj["withdrawal_fee_estimate_output_fee_estimate"], | ||
), | ||
} as WithdrawalFeeEstimateOutput; | ||
}; | ||
export const WithdrawalFeeEstimateOutputToJson = ( | ||
obj: WithdrawalFeeEstimateOutput, | ||
): any => { | ||
return { | ||
withdrawal_fee_estimate_output_fee_estimate: CurrencyAmountToJson( | ||
obj.feeEstimate, | ||
), | ||
}; | ||
}; | ||
|
||
export const FRAGMENT = ` | ||
fragment WithdrawalFeeEstimateOutputFragment on WithdrawalFeeEstimateOutput { | ||
__typename | ||
withdrawal_fee_estimate_output_fee_estimate: fee_estimate { | ||
__typename | ||
currency_amount_original_value: original_value | ||
currency_amount_original_unit: original_unit | ||
currency_amount_preferred_currency_unit: preferred_currency_unit | ||
currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded | ||
currency_amount_preferred_currency_value_approx: preferred_currency_value_approx | ||
} | ||
}`; | ||
|
||
export default WithdrawalFeeEstimateOutput; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved | ||
|
||
/** This is an enum of the potential modes that your Bitcoin withdrawal can take. **/ | ||
export enum WithdrawalMode { | ||
/** | ||
* This is an enum value that represents values that could be added in the future. | ||
* Clients should support unknown values as more of them could be added without notice. | ||
*/ | ||
FUTURE_VALUE = "FUTURE_VALUE", | ||
|
||
WALLET_ONLY = "WALLET_ONLY", | ||
|
||
WALLET_THEN_CHANNELS = "WALLET_THEN_CHANNELS", | ||
} | ||
|
||
export default WithdrawalMode; |
Oops, something went wrong.