1- import type { Multiaddr } from "@multiformats/multiaddr" ;
21import type { InjectedAccountWithMeta } from "@polkadot/extension-inject/types" ;
32import type { TypeRegistry } from "@polkadot/types" ;
43import { Loader2 } from "lucide-react" ;
@@ -12,6 +11,7 @@ import {
1211} from "../components/deal-proposal-form/DealProposalForm" ;
1312import type { FormValues } from "../components/deal-proposal-form/types" ;
1413import { DEFAULT_MAX_PROVE_COMMIT_DURATION , fetchMaxProveCommitDurationConst } from "../lib/consts" ;
14+ import { type ProviderInfo , baseURLFromP2pMultiaddr } from "../lib/conversion" ;
1515import { createSignedRpc , toRpc } from "../lib/dealProposal" ;
1616import { proposeDeal , publishDeal , uploadFile } from "../lib/fileUpload" ;
1717import { loadWrapper } from "../lib/loadWrapper" ;
@@ -28,12 +28,6 @@ type DealInfo = {
2828 endBlock : number ;
2929} ;
3030
31- type ProviderInfo = {
32- accountId : string ;
33- multiaddr : Multiaddr ;
34- pricePerBlock : number ;
35- } ;
36-
3731type DealId = number ;
3832
3933async function executeDeal (
@@ -43,6 +37,8 @@ async function executeDeal(
4337 registry : TypeRegistry ,
4438) : Promise < DealId > {
4539 const { address, port } = providerInfo . multiaddr . nodeAddress ( ) ;
40+ const uploadAddress = baseURLFromP2pMultiaddr ( providerInfo . multiaddr . nodeAddress ( ) ) ;
41+ console . log ( uploadAddress ) ;
4642
4743 const clientAccount = accounts . find ( ( v ) => v . address === dealInfo . proposal . client ) ;
4844 if ( ! clientAccount ) {
@@ -61,12 +57,18 @@ async function executeDeal(
6157 ip : address ,
6258 port : port ,
6359 } ,
60+ uploadAddress ,
6461 ) ;
6562
66- const response = await uploadFile ( dealInfo . file , proposeDealResponse , {
67- ip : address ,
68- port : port ,
69- } ) ;
63+ const response = await uploadFile (
64+ dealInfo . file ,
65+ proposeDealResponse ,
66+ {
67+ ip : address ,
68+ port : port ,
69+ } ,
70+ uploadAddress ,
71+ ) ;
7072 if ( ! response . ok ) {
7173 throw new Error ( response . statusText ) ;
7274 }
@@ -80,10 +82,14 @@ async function executeDeal(
8082 registry ,
8183 clientAccount ,
8284 ) ;
83- const dealId = await publishDeal ( signedRpc , {
84- ip : address ,
85- port : port ,
86- } ) ;
85+ const dealId = await publishDeal (
86+ signedRpc ,
87+ {
88+ ip : address ,
89+ port : port ,
90+ } ,
91+ uploadAddress ,
92+ ) ;
8793
8894 return dealId ;
8995}
0 commit comments