-
Notifications
You must be signed in to change notification settings - Fork 6
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
1 parent
a9f5e3b
commit 3356fa8
Showing
7 changed files
with
238 additions
and
153 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
25 changes: 22 additions & 3 deletions
25
packages/ui-components/src/lib/components/deployment/wizard/FieldDefinitionButtons.svelte
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
30 changes: 30 additions & 0 deletions
30
packages/ui-components/src/lib/components/deployment/wizard/deploymentStore.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,30 @@ | ||
import { writable } from 'svelte/store'; | ||
import type { WizardStep } from '../../../types/wizardSteps'; | ||
|
||
const initialState: { | ||
deploymentSteps: WizardStep[]; | ||
} = { | ||
deploymentSteps: [], | ||
|
||
}; | ||
|
||
const deploymentStore = () => { | ||
const { subscribe, set, update } = writable(initialState); | ||
const reset = () => set(initialState); | ||
// For getting an array of steps from the various input types (deposit, token, vault) | ||
const populateDeploymentSteps = (steps: WizardStep[]) => { | ||
set({ deploymentSteps: steps }); | ||
}; | ||
// For adding a property (binding) to the current step | ||
const updateDeploymentStep = (step: WizardStep) => { | ||
update((state) => ({ ...state, step })); | ||
}; | ||
return { | ||
subscribe, | ||
reset, | ||
updateDeploymentStep, | ||
populateDeploymentSteps | ||
}; | ||
}; | ||
|
||
export default deploymentStore(); |
76 changes: 76 additions & 0 deletions
76
packages/ui-components/src/lib/components/deployment/wizard/getDeploymentSteps.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,76 @@ | ||
import type { TokenOutputStep } from "$lib/types/wizardSteps"; | ||
|
||
import type { DepositStep, FieldStep, TokenInputStep } from "$lib/types/wizardSteps"; | ||
|
||
import type { SelectTokenStep } from "$lib/types/wizardSteps"; | ||
|
||
import type { DotrainOrderGui, GuiFieldDefinition, TokenInfos, Vault , GuiDeposit} from '@rainlanguage/orderbook/js_api'; | ||
import type { WizardStep } from '../../../types/wizardSteps'; | ||
|
||
export const getDeploymentSteps = ( | ||
selectTokens: Map<string, string>, | ||
isLimitStrat: boolean, | ||
allFieldDefinitions: GuiFieldDefinition[], | ||
gui: DotrainOrderGui, | ||
allDeposits: GuiDeposit[], | ||
allTokenInputs: Vault[], | ||
allTokenOutputs: Vault[], | ||
inputVaultIds: string[], | ||
outputVaultIds: string[], | ||
tokenInfos: TokenInfos | ||
) => { | ||
const deploymentSteps: WizardStep[] = [ | ||
...(selectTokens.size > 0 && isLimitStrat | ||
? Array.from(selectTokens.entries()).map( | ||
([token]): SelectTokenStep => ({ | ||
type: 'tokens', | ||
token, | ||
gui, | ||
selectTokens | ||
}) | ||
) | ||
: []), | ||
|
||
...allFieldDefinitions.map( | ||
(fieldDefinition): FieldStep => ({ | ||
type: 'fields', | ||
fieldDefinition, | ||
gui | ||
}) | ||
), | ||
|
||
...allDeposits.map( | ||
(deposit): DepositStep => ({ | ||
type: 'deposits', | ||
deposit, | ||
gui, | ||
tokenInfos | ||
}) | ||
), | ||
|
||
...allTokenInputs.map( | ||
(input, i): TokenInputStep => ({ | ||
type: 'tokenInput', | ||
input, | ||
gui, | ||
tokenInfos, | ||
i, | ||
inputVaultIds | ||
}) | ||
), | ||
|
||
...allTokenOutputs.map( | ||
(output, i): TokenOutputStep => ({ | ||
type: 'tokenOutput', | ||
output, | ||
gui, | ||
tokenInfos, | ||
i, | ||
outputVaultIds | ||
}) | ||
) | ||
]; | ||
|
||
return deploymentSteps; | ||
}; | ||
|
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
Oops, something went wrong.