@@ -45,6 +45,7 @@ import {
4545 CLI_NAME ,
4646 OFFER_FLAG_NAME ,
4747 OFFER_IDS_FLAG_NAME ,
48+ PROVIDER_ADDRESS_FLAG_NAME ,
4849 PROVIDER_ARTIFACTS_CONFIG_FULL_FILE_NAME ,
4950 PROVIDER_CONFIG_FULL_FILE_NAME ,
5051 SINGLE_OFFER_FLAG_NAME ,
@@ -76,7 +77,7 @@ import {
7677 resourceSupplyFromConfigToChain ,
7778} from "../conversions.js" ;
7879import { ptFormatWithSymbol } from "../currencies.js" ;
79- import { assertProviderIsRegistered } from "../providerInfo.js" ;
80+ import { makeProviderAddressValidator } from "../providerInfo.js" ;
8081
8182const MARKET_OFFER_REGISTERED_EVENT_NAME = "MarketOfferRegistered" ;
8283const OFFER_ID_PROPERTY = "offerId" ;
@@ -87,12 +88,19 @@ export type OffersArgs = {
8788 force ?: boolean | undefined ;
8889} ;
8990
91+ export type CreateOffersArgs = OffersArgs & {
92+ [ PROVIDER_ADDRESS_FLAG_NAME ] ?: string | undefined ;
93+ } ;
94+
9095export type SingleOffersArgs = {
9196 [ SINGLE_OFFER_FLAG_NAME ] ?: string | undefined ;
9297 [ SINGLE_OFFER_ID_FLAG_NAME ] ?: string | undefined ;
9398} ;
9499
95- export async function createOffers ( flags : OffersArgs ) {
100+ export async function createOffers (
101+ flags : CreateOffersArgs ,
102+ maybeProviderAddress ?: string ,
103+ ) {
96104 const allOffers = await resolveOffersFromProviderConfig ( flags ) ;
97105 const providerConfig = await ensureReadonlyProviderConfig ( ) ;
98106 const providerConfigPath = providerConfig . $getPath ( ) ;
@@ -164,6 +172,9 @@ export async function createOffers(flags: OffersArgs) {
164172 let addedCPs ;
165173 let offerRegisterTxReceipt ;
166174
175+ const signerAddress = await getSignerAddress ( ) ;
176+ const providerAddress = maybeProviderAddress ?? signerAddress ;
177+
167178 try {
168179 ( {
169180 sliceIndex : registeredCUsCount ,
@@ -174,6 +185,7 @@ export async function createOffers(flags: OffersArgs) {
174185 sliceIndex : allCUs . length ,
175186 getArgs ( computePeersToRegister ) {
176187 return [
188+ providerAddress ,
177189 contracts . deployment . usdc ,
178190 resourcePricesArray ,
179191 setCPUSupplyForCP ( computePeersToRegister ) ,
@@ -183,8 +195,8 @@ export async function createOffers(flags: OffersArgs) {
183195 getTitle ( ) {
184196 return `Register offer: ${ offerName } ` ;
185197 } ,
186- method : contracts . diamond . registerMarketOfferV2 ,
187- validateAddress : assertProviderIsRegistered ,
198+ method : contracts . diamond . registerMarketOfferV2Delegated ,
199+ validateAddress : makeProviderAddressValidator ( providerAddress ) ,
188200 } ) ) ;
189201 } catch ( e ) {
190202 pushOfferRegisterResult ( {
@@ -221,7 +233,6 @@ export async function createOffers(flags: OffersArgs) {
221233 continue ;
222234 }
223235
224- const providerAddress = await getSignerAddress ( ) ;
225236 const offerPerEnv = providerArtifactsConfig . offers [ fluenceEnv ] ?? { } ;
226237 offerPerEnv [ offerName ] = { id : offerId , providerAddress } ;
227238 providerArtifactsConfig . offers [ fluenceEnv ] = offerPerEnv ;
0 commit comments