Skip to content
Open
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
17 changes: 14 additions & 3 deletions src/orders/erc20Fulfillment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,13 @@ export function getErc20Payment(inputData: unknown): Erc20Payment | null {
return null
}

if ("basicOrderParameters" in inputData) {
// The fulfillment API serializes a decoded fulfillBasicOrder call as a single
// `parameters` struct. Older hand-written SDK types called this
// `basicOrderParameters`, so accept that shape as a compatibility fallback.
if (isRecord(inputData.parameters)) {
return basicOrderErc20Payment(inputData.parameters)
}
if (isRecord(inputData.basicOrderParameters)) {
return basicOrderErc20Payment(inputData.basicOrderParameters)
}

Expand Down Expand Up @@ -200,8 +206,13 @@ export function getFulfillerConduitKey(inputData: unknown): string | null {
if (typeof direct === "string") {
return direct
}
if (isRecord(inputData.basicOrderParameters)) {
const fromBasicOrder = inputData.basicOrderParameters.fulfillerConduitKey
const basicOrderParameters = isRecord(inputData.parameters)
? inputData.parameters
: isRecord(inputData.basicOrderParameters)
? inputData.basicOrderParameters
: null
if (basicOrderParameters) {
const fromBasicOrder = basicOrderParameters.fulfillerConduitKey
if (typeof fromBasicOrder === "string") {
return fromBasicOrder
}
Expand Down
8 changes: 5 additions & 3 deletions test/orders/erc20Fulfillment.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,9 @@ function advancedOrderInput(consideration: unknown[]) {
/** basicOrderType 8 is route 2, ERC20_TO_ERC721: the fulfiller pays with ERC20. */
function basicOrderInput(overrides: Record<string, unknown> = {}) {
return {
basicOrderParameters: {
// The fulfillment API serializes fulfillBasicOrder's single decoded struct
// under `parameters`, matching the shape consumed by FulfillmentManager.
parameters: {
considerationToken: USDG,
considerationIdentifier: "0",
considerationAmount: "360000000",
Expand Down Expand Up @@ -170,7 +172,7 @@ describe("getErc20Payment: advanced and standard orders", () => {
})

describe("getErc20Payment: basic orders", () => {
test("sums considerationAmount and additionalRecipients for an ERC20 route", () => {
test("sums considerationAmount and additionalRecipients from the API parameters shape", () => {
expect(getErc20Payment(basicOrderInput())).toEqual({
token: USDG,
amount: 369000000n,
Expand Down Expand Up @@ -252,7 +254,7 @@ describe("getFulfillerConduitKey", () => {
expect(getFulfillerConduitKey(advancedOrderInput([]))).toBe(CONDUIT_KEY)
})

test("reads the key nested in basicOrderParameters", () => {
test("reads the key nested in the basic-order API parameters", () => {
expect(getFulfillerConduitKey(basicOrderInput())).toBe(CONDUIT_KEY)
})

Expand Down