-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
53 changed files
with
2,571 additions
and
278 deletions.
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
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,37 @@ | ||
import { Contract } from "starknet"; | ||
|
||
import { Config } from "../../createConfig.js"; | ||
|
||
export const ABI = [ | ||
{ | ||
type: "struct", | ||
name: "ark_oz::erc2981::fees::FeesRatio", | ||
members: [ | ||
{ name: "numerator", type: "core::integer::u256" }, | ||
{ name: "denominator", type: "core::integer::u256" } | ||
] | ||
}, | ||
{ | ||
type: "function", | ||
name: "get_ark_fees", | ||
inputs: [], | ||
outputs: [{ type: "ark_oz::erc2981::fees::FeesRatio" }], | ||
state_mutability: "view" | ||
} | ||
] as const; | ||
|
||
export async function getArkFees(config: Config) { | ||
const contract = new Contract( | ||
ABI, | ||
config.starknetExecutorContract, | ||
config.starknetProvider | ||
).typedv2(ABI); | ||
|
||
const { numerator, denominator } = await contract.get_ark_fees(); | ||
|
||
return { | ||
formatted: ((Number(numerator) / Number(denominator)) * 100).toFixed(2), | ||
numerator, | ||
denominator | ||
}; | ||
} |
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 @@ | ||
import { CallData, Contract } from "starknet"; | ||
|
||
import { Config } from "../../createConfig.js"; | ||
|
||
export const ABI = [ | ||
{ | ||
type: "struct", | ||
name: "ark_oz::erc2981::fees::FeesRatio", | ||
members: [ | ||
{ name: "numerator", type: "core::integer::u256" }, | ||
{ name: "denominator", type: "core::integer::u256" } | ||
] | ||
}, | ||
{ | ||
type: "function", | ||
name: "get_broker_fees", | ||
inputs: [ | ||
{ | ||
name: "broker_address", | ||
type: "core::starknet::contract_address::ContractAddress" | ||
} | ||
], | ||
outputs: [{ type: "ark_oz::erc2981::fees::FeesRatio" }], | ||
state_mutability: "view" | ||
} | ||
] as const; | ||
|
||
export async function getBrokerFees(config: Config, brokerAddress: string) { | ||
const contract = new Contract( | ||
ABI, | ||
config.starknetExecutorContract, | ||
config.starknetProvider | ||
).typedv2(ABI); | ||
|
||
const { numerator, denominator } = await contract.get_broker_fees( | ||
CallData.compile({ | ||
broker_address: brokerAddress | ||
}) | ||
); | ||
|
||
return { | ||
formatted: ((Number(numerator) / Number(denominator)) * 100).toFixed(2), | ||
numerator, | ||
denominator | ||
}; | ||
} |
62 changes: 62 additions & 0 deletions
62
packages/core/src/actions/fees/getCollectionCreatorFees.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,62 @@ | ||
import { CallData, Contract } from "starknet"; | ||
import { toHex } from "viem"; | ||
|
||
import { Config } from "../../createConfig.js"; | ||
|
||
export const ABI = [ | ||
{ | ||
type: "struct", | ||
name: "ark_oz::erc2981::fees::FeesRatio", | ||
members: [ | ||
{ name: "numerator", type: "core::integer::u256" }, | ||
{ name: "denominator", type: "core::integer::u256" } | ||
] | ||
}, | ||
{ | ||
type: "function", | ||
name: "get_collection_creator_fees", | ||
inputs: [ | ||
{ | ||
name: "nft_address", | ||
type: "core::starknet::contract_address::ContractAddress" | ||
} | ||
], | ||
outputs: [ | ||
{ | ||
type: "(core::starknet::contract_address::ContractAddress, ark_oz::erc2981::fees::FeesRatio)" | ||
} | ||
], | ||
state_mutability: "view" | ||
} | ||
] as const; | ||
|
||
export async function getCollectionCreatorFees( | ||
config: Config, | ||
tokenAddress: string | ||
) { | ||
const contract = new Contract( | ||
ABI, | ||
config.starknetExecutorContract, | ||
config.starknetProvider | ||
).typedv2(ABI); | ||
|
||
const raw = await contract.get_collection_creator_fees( | ||
CallData.compile({ | ||
nft_address: tokenAddress | ||
}) | ||
); | ||
const creator = toHex(raw[0] as bigint); | ||
const { numerator, denominator } = raw[1] as { | ||
numerator: bigint; | ||
denominator: bigint; | ||
}; | ||
|
||
return { | ||
creator, | ||
fees: { | ||
formatted: ((Number(numerator) / Number(denominator)) * 100).toFixed(2), | ||
numerator, | ||
denominator | ||
} | ||
}; | ||
} |
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,50 @@ | ||
import { Contract } from "starknet"; | ||
import { toHex } from "viem"; | ||
|
||
import { Config } from "../../createConfig.js"; | ||
|
||
export const ABI = [ | ||
{ | ||
type: "struct", | ||
name: "ark_oz::erc2981::fees::FeesRatio", | ||
members: [ | ||
{ name: "numerator", type: "core::integer::u256" }, | ||
{ name: "denominator", type: "core::integer::u256" } | ||
] | ||
}, | ||
{ | ||
type: "function", | ||
name: "get_default_creator_fees", | ||
inputs: [], | ||
outputs: [ | ||
{ | ||
type: "(core::starknet::contract_address::ContractAddress, ark_oz::erc2981::fees::FeesRatio)" | ||
} | ||
], | ||
state_mutability: "view" | ||
} | ||
] as const; | ||
|
||
export async function getDefaultCreatorFees(config: Config) { | ||
const contract = new Contract( | ||
ABI, | ||
config.starknetExecutorContract, | ||
config.starknetProvider | ||
).typedv2(ABI); | ||
|
||
const raw = await contract.get_default_creator_fees(); | ||
const creator = toHex(raw[0] as bigint); | ||
const { numerator, denominator } = raw[1] as { | ||
numerator: bigint; | ||
denominator: bigint; | ||
}; | ||
|
||
return { | ||
creator, | ||
fees: { | ||
formatted: ((Number(numerator) / Number(denominator)) * 100).toFixed(2), | ||
numerator, | ||
denominator | ||
} | ||
}; | ||
} |
Oops, something went wrong.